From d26b0c16ade725da65da51489b768c4ca18d7d7b Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Thu, 7 Apr 2022 15:57:22 +0100 Subject: [PATCH] save --- src/app/guards/inactivity.guard.ts | 26 +++++++++++--------------- src/app/pages/login/login.page.ts | 14 +++++++------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/app/guards/inactivity.guard.ts b/src/app/guards/inactivity.guard.ts index a3e56ca7f..f3a06be73 100644 --- a/src/app/guards/inactivity.guard.ts +++ b/src/app/guards/inactivity.guard.ts @@ -4,19 +4,16 @@ import { Observable } from 'rxjs'; import { SessionStore } from '../store/session.service'; import { AlertController, Platform } from '@ionic/angular'; import { PermissionService } from '../services/permission.service'; -import { PermissionList } from '../models/permission/permissionList'; @Injectable({ providedIn: 'root' }) export class InactivityGuard implements CanActivate { - permissionList = new PermissionList(); - constructor( private router:Router, private platform: Platform, - public permissionService: PermissionService, + public p: PermissionService, private alertController: AlertController ) {} @@ -26,14 +23,13 @@ export class InactivityGuard implements CanActivate { if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - console.log(this.permissionList); - if(this.permissionService.userPermission(this.permissionList.Agenda.access) || this.permissionService.userPermission(this.permissionList.Gabinete.access)){ + if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ this.router.navigate(['/home/events']); } - else if(this.permissionService.userPermission(this.permissionList.Chat.access) && this.permissionService.userPermission(this.permissionList.Actions.access)){ + else if(this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)){ this.router.navigate(['/home/chat']); } - else if(this.permissionService.userPermission(this.permissionList.Actions.access)){ + else if(this.p.userPermission(this.p.permissionList.Actions.access)){ this.router.navigate(['/home/publications']); } else { @@ -43,15 +39,15 @@ export class InactivityGuard implements CanActivate { buttons: [{ text: 'Ok', handler: () => { - + } }] }).then( async (alertPopup) => { await alertPopup.present(); }) - + } - + return false } else if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin ) { return true @@ -60,13 +56,13 @@ export class InactivityGuard implements CanActivate { }//Mobile or Tablet without session else { - if(this.permissionService.userPermission(this.permissionList.Agenda.access) || this.permissionService.userPermission(this.permissionList.Gabinete.access)){ + if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ this.router.navigate(['/home/events']); } - else if(this.permissionService.userPermission(this.permissionList.Chat.access) && this.permissionService.userPermission(this.permissionList.Actions.access)){ + else if(this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)){ this.router.navigate(['/home/chat']); } - else if(this.permissionService.userPermission(this.permissionList.Actions.access)){ + else if(this.p.userPermission(this.p.permissionList.Actions.access)){ this.router.navigate(['/home/publications']); } else { this.alertController.create({ @@ -75,7 +71,7 @@ export class InactivityGuard implements CanActivate { buttons: [{ text: 'Ok', handler: () => { - + } }] }).then( async (alertPopup)=>{ diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 4ed0d7480..655e60d2b 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -109,10 +109,10 @@ export class LoginPage implements OnInit { await this.authService.SetSession(attempt, this.userattempt); - console.log(this.p.userPermission(this.permissionList.Chat.access)); + console.log(this.p.userPermission(this.p.permissionList.Chat.access)); - if(this.p.userPermission(this.permissionList.Chat.access)){ + if(this.p.userPermission(this.p.permissionList.Chat.access)){ await this.authService.loginChat(); await this.authService.loginToChatWs(); } @@ -132,7 +132,7 @@ export class LoginPage implements OnInit { this.changeProfileService.run(); - if(this.p.userPermission(this.permissionList.Chat.access)){ + if(this.p.userPermission(this.p.permissionList.Chat.access)){ await this.authService.loginChat(); await this.authService.loginToChatWs(); } @@ -154,7 +154,7 @@ export class LoginPage implements OnInit { this.toastService._badRequest('Por favor, insira o seu nome de utilizador'); } - + } goback() { @@ -162,13 +162,13 @@ export class LoginPage implements OnInit { if(pathName) { this.router.navigate([pathName]); } else { - if(this.p.userPermission(this.permissionList.Agenda.access) || this.p.userPermission(this.permissionList.Gabinete.access)){ + if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ this.router.navigate(['/home/events']); } - else if(this.p.userPermission(this.permissionList.Chat.access) && this.p.userPermission(this.permissionList.Actions.access)){ + else if(this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)){ this.router.navigate(['/home/chat']); } - else if(this.p.userPermission(this.permissionList.Actions.access)){ + else if(this.p.userPermission(this.p.permissionList.Actions.access)){ this.router.navigate(['/home/publications']); } }