0

I have a angular application with api calls being made to back end for logging and and so forth. What i need is to be able to tell when the session expires and logged the user out.

I know on every route change i can check if the user is logged in or not which i do right now but how can i handle it when they are idle. So i have instances where the user is on a specific page and remains inactive and although they are logged out in the back end i do not know on the front end and need some where to constantly be checking. Any solutions for the best method.

Yeak
  • 2,470
  • 9
  • 45
  • 71
  • possible duplicate of [Auto logout with Angularjs based on idle user](http://stackoverflow.com/questions/19168330/auto-logout-with-angularjs-based-on-idle-user) – Buu Nov 07 '14 at 00:39

1 Answers1

0

A client-side solution without polling:

(re)start a timer at each route change to show a message after 15(this number should coincide with the amount of time the user is logged out in the back-end) minutes.

The only downside to this is that if your app sends data outside of route changes the user could receive of notification of being logged out while the user is still logged in.

It would also require that your route changes actually send a request to the back-end.

Rohan
  • 8,006
  • 5
  • 24
  • 32