diff --git a/src/app/guards/inactivity.guard.ts b/src/app/guards/inactivity.guard.ts index 3c4e68c55..bfd436d18 100644 --- a/src/app/guards/inactivity.guard.ts +++ b/src/app/guards/inactivity.guard.ts @@ -24,14 +24,22 @@ export class InactivityGuard implements CanActivate { 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)){ - this.router.navigate(['/home/events']); + //When user has got access to Agenda but does not have their own calendar, goes to Agenda + if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){ + this.router.navigate(['/home/agenda']); + } + else{ + this.router.navigate(['/home/events']); + } } + //If user has access permission to both Chat and Action, goes to Chat by default. else if((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)){ this.router.navigate(['/home/chat']); } else if(this.p.userPermission(this.p.permissionList.Actions.access)){ this.router.navigate(['/home/publications']); - } else { + } + else { this.alertController.create({ cssClass: 'my-custom-class', @@ -57,14 +65,22 @@ export class InactivityGuard implements CanActivate { else { if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ - this.router.navigate(['/home/events']); + //When user has got access to Agenda but does not have their own calendar, goes to Agenda + if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){ + this.router.navigate(['/home/agenda']); + } + else{ + this.router.navigate(['/home/events']); + } } + //If user has access permission to both Chat and Action, goes to Chat by default. else if((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)){ this.router.navigate(['/home/chat']); } else if(this.p.userPermission(this.p.permissionList.Actions.access)){ this.router.navigate(['/home/publications']); - } else { + } + else { this.alertController.create({ cssClass: 'my-custom-class', header: 'Utilizador sem acesso a aplicação', diff --git a/src/app/pages/inactivity/inactivity.page.ts b/src/app/pages/inactivity/inactivity.page.ts index f53df3185..a6d0d98ef 100644 --- a/src/app/pages/inactivity/inactivity.page.ts +++ b/src/app/pages/inactivity/inactivity.page.ts @@ -205,8 +205,15 @@ export class InactivityPage implements OnInit { setTimeout(()=>{ if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ - this.router.navigate(['/home/events'], {replaceUrl: true}); + //When user has got access to Agenda but does not have their own calendar, goes to Agenda + if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){ + this.router.navigate(['/home/agenda']); + } + else{ + this.router.navigate(['/home/events']); + } } + //If user has access permission to both Chat and Action, goes to Chat by default. else if((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)){ this.router.navigate(['/home/chat']); } @@ -228,8 +235,15 @@ export class InactivityPage implements OnInit { SessionStore.setPin(code); if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ - this.router.navigate(['/home/events']); + //When user has got access to Agenda but does not have their own calendar, goes to Agenda + if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){ + this.router.navigate(['/home/agenda']); + } + else{ + this.router.navigate(['/home/events']); + } } + //If user has access permission to both Chat and Action, goes to Chat by default. else if((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)){ this.router.navigate(['/home/chat']); } diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 308d8543e..751c3cb26 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -163,8 +163,15 @@ export class LoginPage implements OnInit { this.router.navigate([pathName]); } else { if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){ - this.router.navigate(['/home/events']); + //When user has got access to Agenda but does not have their own calendar, goes to Agenda + if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user.OwnerCalendars.length == 0){ + this.router.navigate(['/home/agenda']); + } + else{ + this.router.navigate(['/home/events']); + } } + //If user has access permission to both Chat and Action, goes to Chat by default. else if((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)){ this.router.navigate(['/home/chat']); }