mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
|
import { Observable } from 'rxjs';
|
|
import { SessionStore } from '../store/session.service';
|
|
import { Platform } from '@ionic/angular';
|
|
import { RouteService } from 'src/app/services/route.service'
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class LoginGuard implements CanActivate {
|
|
constructor(
|
|
private router:Router,
|
|
private platform: Platform,
|
|
private RouteService: RouteService ) {
|
|
|
|
}
|
|
canActivate(
|
|
route: ActivatedRouteSnapshot,
|
|
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
|
|
|
if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) {
|
|
this.router.navigate(['/home/events']);
|
|
return false
|
|
} else if(SessionStore.exist && !SessionStore.hasPin && !this.platform.is('desktop') && !this.platform.is('mobileweb') ) {
|
|
this.router.navigate(['/pin']);
|
|
return false
|
|
} else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin' && !this.platform.is('desktop') && !this.platform.is('mobileweb')) {
|
|
this.router.navigate(['/inactivity']);
|
|
return false
|
|
|
|
} else {
|
|
return true
|
|
}
|
|
}
|
|
|
|
}
|