This commit is contained in:
tiago.kayaya
2021-09-02 13:22:10 +01:00
18 changed files with 355 additions and 221 deletions
+10 -4
View File
@@ -3,24 +3,30 @@ import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Rout
import { Observable } from 'rxjs';
import { LocalstoreService } from '../store/localstore.service';
import { SessionStore } from '../store/session.service';
import { AlertController, Platform } from '@ionic/angular';
@Injectable({
providedIn: 'root'
})
export class LoginGuard implements CanActivate {
constructor( private router:Router,
private localstoreService: LocalstoreService) {
constructor( private router:Router, private platform: Platform,) {
}
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if(window.location.pathname == '/' && SessionStore.exist ) {
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;
return true
}
}