2021-08-27 13:39:52 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
import { SessionStore } from '../store/session.service';
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class InactivityGuard implements CanActivate {
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private router:Router
|
|
|
|
|
){}
|
|
|
|
|
|
|
|
|
|
canActivate(
|
|
|
|
|
route: ActivatedRouteSnapshot,
|
|
|
|
|
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
|
|
|
|
|
2021-08-30 11:41:21 +01:00
|
|
|
if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin ) {
|
2021-08-27 13:39:52 +01:00
|
|
|
return true
|
2021-08-27 17:11:05 +01:00
|
|
|
} else if(SessionStore.exist && !SessionStore.user.Inactivity) {
|
2021-08-27 13:39:52 +01:00
|
|
|
return true
|
|
|
|
|
} else {
|
|
|
|
|
this.router.navigate(['/home/events']);
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|