mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
save
This commit is contained in:
@@ -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)=>{
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user