How to manage login sessions from Angular

Discussão em 'Angular' iniciado por Jonathan JV, Março 28, 2025.

  1. Jonathan JV

    Jonathan JV Guest

    today i wanna get some help with some ideas about how manage the login sessions in Angular, Im new using this framework an i know how to use it but today i started with auth functionalities and i got a lot of questions.

    So let me explain, i have a backend in NestJs with all endpoints to Auth functions im using jwt, my questions started when i wanna use it in my frontend. I have a service and all things to show a user ui to make login but my questions started when i thinked "Whats the best practice to mantain a login session in my frontend?", i mean, i dont know if exists some rules about how mantain login session in Angular. My first idea was this, make a service that save token and user data of the auth in localStorage and after that use that data to make requests using a interceptor to send the bearer token. Now, with that all a user can make login and that things but How can i manage tokens expired? i dont wanna add a lot of catchError() in each observable to redirect a user to make a login again. Can somebody help me with that questions please? :(

    Continue reading...

Compartilhe esta Página