loopback-sdk-builder
loopback-sdk-builder copied to clipboard
Auto logout after a period of inactivity
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?
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
Mmh, I'm not sure I didn't understand this approach, could you please explain more?