loopback-sdk-builder icon indicating copy to clipboard operation
loopback-sdk-builder copied to clipboard

Auto logout after a period of inactivity

Open pierfreeman opened this issue 7 years ago • 2 comments

What type of issue are you creating?

  • [ ] Bug
  • [ ] Enhancement
  • [x] Question

What version of this module are you using?

  • [ ] 2.0.10 (Stable)
  • [x] 2.1.0-rc.13.5
  • [ ] Other

Please add a description for your issue:

Is there a way to implement a service which performs auto-logout after a period of inactivity? The behavious is well-described here: https://blog.sstorie.com/building-an-angular-2-reactive-auto-logout-timer-with-the-redux-pattern/ , but introducing redux pattern into my application is a bit impracticable right now.

I found this on the Loopback github: https://github.com/strongloop/loopback-sdk-angular/issues/39 which describes a way...for angular 1.

In this moment I'm trying to develop a wrapping service for auth and login for managing the redirect to the login page when the access token becomes invalid (by handling 401 error in API requests)...but I'd like to extend it also when the user stops interacting with the app for an extended period of time, both leaving open and closing the browser tab.

Any suggestion? Anyone already stepped into this issue?

pierfreeman avatar Sep 25 '17 12:09 pierfreeman

Hi @pierfreeman thanks for reaching out,

Hey so.. For this case I believe you would need to use the customHeaders param within your api services, the downside is that each service has its own customHeader, but right now there is no general custom header that will be set for all calls, like interceptors in angular 1.

We might actually need add a method within the LoopBackConfig to set customHeaders for any of the calls

jonathan-casarrubias avatar Oct 05 '17 13:10 jonathan-casarrubias

Mmh, I'm not sure I didn't understand this approach, could you please explain more?

pierfreeman avatar Oct 06 '17 08:10 pierfreeman