#Pop up a modal when a user session about to expire

11 messages · Page 1 of 1 (latest)

carmine violet
#

Hi, I am using jwt token and I want to implement a session expire smh when a jwt token about to expire a pop up window will show to notify the user to extend or log out. How can I implement something like this?Do I need a refresher token? or Do I need a session? Please advise.

tropic crane
#

I dunno exactly what jwt is but if you know how long the expire is you can do a settimeout for that length - some change and make a modal pop up once it reaches the settimeout

carmine violet
#

yes I know how long it will expire and how will I do the set time out in angular?

jaunty hawk
carmine violet
#

Thank you will take a look into this

carmine violet
#

Hi, How to make it global? I want to make the code only on a one component and be used by all the component. should I put it in appcomponent? or is there a configuration?

jaunty hawk
#

g!toh you should learn about services. This is covered by the tour of heroes tutorial

sleek shoalBOT
#

Hi @jaunty hawk, welcome to angular

We recommend you start your Angular journey with the Tour of Heroes tutorial, located here: https://angular.io/tutorial.

carmine violet
#

Hi jbnizet, I think timer runs globally already. maybe I don't need a service. is it correct?

#

I mean, if I am in home or any component that timer is still running right? but I have not tried it yet. I am still watching the tutorials. I have to test it if I move to another pages, will the timer resets or will just to continue to run. I am putting the code inside app.component.

jaunty hawk
#

Yes, the timer will be global. But if you want to start it or stop it or whatever from anywhere, it should be inside a service.