This commit is contained in:
tiago.kayaya
2022-04-07 15:57:22 +01:00
parent e631cfa8e2
commit d26b0c16ad
2 changed files with 18 additions and 22 deletions
+11 -15
View File
@@ -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)=>{
+7 -7
View File
@@ -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']);
}
}