add inactivity page

This commit is contained in:
Peter Maquiran
2021-08-27 13:39:52 +01:00
parent 6aec4a1d5f
commit 230ea00341
20 changed files with 344 additions and 210 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { LocalstoreService } from '../store/localstore.service';
import { SessionStore } from '../store/session.service';
@Injectable({
providedIn: 'root'
@@ -16,7 +17,7 @@ export class AuthGuard implements CanActivate {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if(window.location.pathname != '' && !this.localstoreService.get('UserData', false)) {
if(window.location.pathname != '' && !SessionStore.exist) {
this.router.navigate(['/']);
return false
} else {
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { InactivityGuard } from './inactivity.guard';
describe('InactivityGuard', () => {
let guard: InactivityGuard;
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(InactivityGuard);
});
it('should be created', () => {
expect(guard).toBeTruthy();
});
});
+35
View File
@@ -0,0 +1,35 @@
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 {
alert(SessionStore.exist+ ' '+SessionStore.user.Inativity+ ' '+ SessionStore.hasPin)
if(SessionStore.exist && SessionStore.user.Inativity && !SessionStore.hasPin) {
alert('stay set pin')
return true
} else if(SessionStore.exist && SessionStore.user.Inativity) {
alert('stay cofirm')
return true
} else {
alert('goint')
this.router.navigate(['/home/events']);
return false
}
}
}
+2 -1
View File
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { LocalstoreService } from '../store/localstore.service';
import { SessionStore } from '../store/session.service';
@Injectable({
providedIn: 'root'
@@ -15,7 +16,7 @@ export class LoginGuard implements CanActivate {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if(window.location.pathname == '/' && this.localstoreService.get('UserData', null) != null ) {
if(window.location.pathname == '/' && SessionStore.exist ) {
this.router.navigate(['/home/events']);
return false
} else {