29 lines
932 B
TypeScript
29 lines
932 B
TypeScript
import { Component } from '@angular/core';
|
|
import { BnNgIdleService } from 'bn-ng-idle';
|
|
import {SessionDataProviderService} from "./store/session-data-provider.service";
|
|
import {Router} from "@angular/router"; // import it to your component
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
templateUrl: 'app.component.html',
|
|
styleUrls: ['app.component.scss'],
|
|
})
|
|
export class AppComponent {
|
|
constructor(private bnIdle: BnNgIdleService,private sessionDataProviderService : SessionDataProviderService, public router: Router) {
|
|
// this.OneSignalInit();
|
|
this.bnIdle.startWatching(2500).subscribe((res) => {
|
|
if(res) {
|
|
console.log("session expired");
|
|
// alert('LOG OUT NOW');
|
|
this.sessionDataProviderService.DestroySessionOnLogout();
|
|
this.router.navigate(['login']);
|
|
}
|
|
})
|
|
}
|
|
|
|
// Call this function when your app starts
|
|
OneSignalInit(): void {
|
|
console.log('Moved to home');
|
|
}
|
|
}
|