diff --git a/src/app/guards/inactivity.guard.ts b/src/app/guards/inactivity.guard.ts index bf19b3a05..acb8555cc 100644 --- a/src/app/guards/inactivity.guard.ts +++ b/src/app/guards/inactivity.guard.ts @@ -23,7 +23,7 @@ export class InactivityGuard implements CanActivate { console.log('hire inactinity!', state.url) - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + if ((this.platform.is('desktop') || this.platform.is('mobileweb')) && (SessionStore?.user?.Inactivity) ) { if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ this.router.navigate(['/home/events']); } @@ -64,29 +64,33 @@ export class InactivityGuard implements CanActivate { }//Mobile or Tablet without session else { - if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ - this.router.navigate(['/home/events']); + if((SessionStore?.user?.Inactivity)) { + 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.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)){ + this.router.navigate(['/home/chat']); + } + else if(this.p.userPermission(this.p.permissionList.Actions.access)){ + this.router.navigate(['/home/publications']); + } else { + this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Utilizador sem acesso a aplicação', + buttons: [{ + text: 'Ok', + handler: () => { + + } + }] + }).then( async (alertPopup)=>{ + await alertPopup.present(); + }) + } + return false } - 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.p.permissionList.Actions.access)){ - this.router.navigate(['/home/publications']); - } else { - this.alertController.create({ - cssClass: 'my-custom-class', - header: 'Utilizador sem acesso a aplicação', - buttons: [{ - text: 'Ok', - handler: () => { - } - }] - }).then( async (alertPopup)=>{ - await alertPopup.present(); - }) - } - return false + } } diff --git a/src/app/guards/login.guard.ts b/src/app/guards/login.guard.ts index e191945c4..dd141113a 100644 --- a/src/app/guards/login.guard.ts +++ b/src/app/guards/login.guard.ts @@ -21,18 +21,20 @@ export class LoginGuard implements CanActivate { if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) { + // enter app this.router.navigate(['/home/events']); return false } else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin' && SessionStore.forceToLoginWithForceToLogInWithPassword && !this.platform.is('desktop') && !this.platform.is('mobileweb')) { + // login with password while has pin SessionStore.forceToLoginWithForceToLogInWithPassword = false return true - } else if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin && !this.platform.is('desktop') && !this.platform.is('mobileweb') ) { + } else if(SessionStore.exist && !this.platform.is('desktop') && !this.platform.is('mobileweb') ) { + // go to pin page 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 }