Merge branch 'develop_bitOut-fix' into consoleCle

This commit is contained in:
Eudes Inácio
2022-12-21 15:11:50 +01:00
3 changed files with 43 additions and 33 deletions
+9 -8
View File
@@ -22,14 +22,15 @@ export class AuthGuard implements CanActivate {
route: ActivatedRouteSnapshot, route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
// if user not active // if user not active or no session
if(!SessionStore.user.Inactivity) { if(!SessionStore.user.Inactivity || !SessionStore.exist) {
this.router.navigate(['/']);
return false if(SessionStore.user.LoginPreference == 'Pin') {
} this.router.navigate(['/pin']);
// if session doesn't exit } else {
else if(!SessionStore.exist) { this.router.navigate(['/']);
this.router.navigate(['/']); }
return false return false
} else { } else {
+30 -23
View File
@@ -23,7 +23,7 @@ export class InactivityGuard implements CanActivate {
console.log('hire inactinity!', state.url) console.log('hire inactinity!', state.url)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) { if ( (this.platform.is('desktop') || this.platform.is('mobileweb')) ) {
if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.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']); this.router.navigate(['/home/events']);
} }
@@ -56,7 +56,10 @@ export class InactivityGuard implements CanActivate {
} else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin') { } else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin') {
// inactivity login // inactivity login
return true return true
} else if (SessionStore.user.LoginPreference != 'Pin' && !SessionStore.user.Inactivity) { } else if (!SessionStore.user.Inactivity && this.platform.is('mobile')) {
// try to login
return true
} else if (SessionStore.user.LoginPreference != 'Pin' && SessionStore.hasPin) {
// no right to be in this page // no right to be in this page
this.router.navigateByUrl('/', { replaceUrl: true }); this.router.navigateByUrl('/', { replaceUrl: true });
@@ -64,29 +67,33 @@ export class InactivityGuard implements CanActivate {
}//Mobile or Tablet without session }//Mobile or Tablet without session
else { else {
if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ if((SessionStore?.user?.Inactivity)) {
this.router.navigate(['/home/events']); 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
} }
} }
+4 -2
View File
@@ -21,18 +21,20 @@ export class LoginGuard implements CanActivate {
if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) { if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) {
// enter app
this.router.navigate(['/home/events']); this.router.navigate(['/home/events']);
return false return false
} else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin' && SessionStore.forceToLoginWithForceToLogInWithPassword && !this.platform.is('desktop') && !this.platform.is('mobileweb')) { } 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 SessionStore.forceToLoginWithForceToLogInWithPassword = false
return true 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('mobile') && SessionStore.user.LoginPreference == 'Pin' ) {
// go to pin page
this.router.navigate(['/pin']); this.router.navigate(['/pin']);
return false return false
} else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin' && !this.platform.is('desktop') && !this.platform.is('mobileweb')) { } else if(SessionStore.exist && !SessionStore.user.Inactivity && SessionStore.user.LoginPreference == 'Pin' && !this.platform.is('desktop') && !this.platform.is('mobileweb')) {
this.router.navigate(['/inactivity']); this.router.navigate(['/inactivity']);
return false return false
} else { } else {
return true return true
} }