ng-sess-timeout
v0.0.2
Published
ng-sess-timeout =======
Downloads
4
Maintainers
Readme
ng-sess-timeout
About
For implementing the session timeout login on front end. I have tried to keep it very simple but it will serve the purpose..
========
Authored by Naveen Shrinag mail- [email protected]
Requirements
- Angular 5 or later.
Getting Started (Example)
installation : npm install ng-sess-timeout
import NgTimeoutModule on your app.module.ts
.... import {NgTimeoutModule} from 'ng-sess-timeout';
@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, NgTimeoutModule, ... ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
import {NgTimeout} from 'ng-sess-timeout'; // import to the component where you want to use this ....
export class AppComponent {
constructor(private sessTimer:NgTimeout) { } ngOnInit() { // set the session timeout time in minutes this.sessTimer.timer = 1; // subscribe to timeExpired to know if session has exprired. returns true (session expired) and false. this.sessTimer.timeExpired.subscribe((value)=> { console.log(value); }) // suscribe to timeLeft to know how much time (in seconds) is left before session timeout this.sessTimer.timeLeft.subscribe((time)=> { console.log(time); }) // to stop the timer but any user movement will again trigger it. this.sessTimer.stop(); // use to reset the timer this.sessTimer.reset(); // call to stop method on ngDestroy and unsubscribe, failing which can lead to unexpected errors. }
}