mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
improve
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user