This commit is contained in:
Peter Maquiran
2023-01-03 21:08:49 +01:00
parent f7aae9aa00
commit fcc8bc6b74
20 changed files with 356 additions and 68 deletions
+75 -4
View File
@@ -6,16 +6,23 @@ import { PermissionService } from '../services/permission.service';
import { LocalstoreService } from '../store/localstore.service';
import { SessionStore } from '../store/session.service';
import { RouteService } from 'src/app/services/route.service'
import { InformationPage } from 'src/app/modals/information/information.page'
import { FirstEnterService } from 'src/app/services/first-enter.service'
// import { ModalController } from '@ionic/angular';
import { AlertController, Platform } from '@ionic/angular';
@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(
private router:Router,
private localstoreService: LocalstoreService,
private authService: AuthService,
public p: PermissionService,
private RouteService: RouteService
private RouteService: RouteService,
private FirstEnterService: FirstEnterService,
private InformationPage: InformationPage,
private alertController: AlertController,
// private modalController: ModalController,
){}
canActivate(
@@ -41,7 +48,39 @@ export class AuthGuard implements CanActivate {
if(pathname.startsWith('/home/agenda')) {
if(this.p.userPermission(this.p.permissionList.Agenda.access)) {
return true;
if((SessionStore.user.OwnerCalendars.length != 0 || SessionStore.user.SharedCalendars.length != 0)) {
return true
}
if(['/pin','/login', '/inactivity' , '', '/'].includes(window.location.pathname)) {
this.FirstEnterService.enter()
setTimeout(() => {
// this.modalController.create({
// component: InformationPage,
// componentProps: {
// },
// cssClass: 'discart-expedient-modal',
// backdropDismiss: false
// });
// this.alertController.create({
// cssClass: 'my-custom-class',
// header: 'utilizador não tem calendário',
// buttons: [{
// text: 'Ok',
// handler: () => {
// }
// }]
// }).then( async (alertPopup) => {
// await alertPopup.present();
// })
}, 1000)
}
return false;
} else {
this.router.navigate(['/login']);
return false;
@@ -59,6 +98,38 @@ export class AuthGuard implements CanActivate {
}
else if(pathname.startsWith('/home/chat')) {
if(this.p.userPermission(this.p.permissionList.Chat.access)) {
if(!SessionStore.user.ChatData?.data) {
if(['/pin','/login', '/inactivity' , '', '/'].includes(window.location.pathname)) {
this.FirstEnterService.enter()
setTimeout(() => {
// this.modalController.create({
// component: InformationPage,
// componentProps: {
// },
// cssClass: 'discart-expedient-modal',
// backdropDismiss: false
// });
// this.alertController.create({
// cssClass: 'my-custom-class',
// header: 'Serviço temporariamente indisponível',
// buttons: [{
// text: 'Ok',
// handler: () => {
// }
// }]
// }).then( async (alertPopup) => {
// await alertPopup.present();
// })
}, 1000)
}
return false
}
return true;
} else {
this.router.navigate(['/login']);