add further permission on the navigation

This commit is contained in:
tiago.kayaya
2022-03-29 16:49:51 +01:00
parent 5a4a7562fa
commit 4684ed1e98
5 changed files with 53 additions and 17 deletions
+24 -9
View File
@@ -12,6 +12,8 @@ import { ChangeProfileService } from 'src/app/services/change-profile.service';
import { ThemeService } from 'src/app/services/theme.service';
import { StorageService } from 'src/app/services/storage.service';
import { ChatService } from 'src/app/services/chat.service';
import { PermissionService } from 'src/app/services/permission.service';
import { PermissionList } from 'src/app/models/permissionList';
@Component({
selector: 'app-login',
@@ -29,7 +31,8 @@ export class LoginPage implements OnInit {
hasPin: boolean
loginPreference: string
sessionStore = SessionStore
sessionStore = SessionStore;
permissionList = new PermissionList();
constructor(
private notificatinsservice: NotificationsService,
@@ -40,7 +43,8 @@ export class LoginPage implements OnInit {
private clearStoreService: ClearStoreService,
private changeProfileService: ChangeProfileService,
public ThemeService: ThemeService,
private storageservice: StorageService
private storageservice: StorageService,
public permissionService: PermissionService,
) {}
ngOnInit() {
@@ -101,26 +105,29 @@ export class LoginPage implements OnInit {
// login to API successfully
if (attempt) {
if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
await this.authService.loginChat();
await this.authService.loginToChatWs()
await this.authService.loginToChatWs();
this.getToken();
SessionStore.setInativity(true);
this.goback()
this.goback();
} else {
this.clearStoreService.clear()
SessionStore.delete()
this.clearStoreService.clear();
SessionStore.delete();
window.localStorage.clear();
await this.authService.SetSession(attempt, this.userattempt);
this.changeProfileService.run()
this.changeProfileService.run();
await this.authService.loginChat();
await this.authService.loginToChatWs()
await this.authService.loginToChatWs();
this.getToken();
this.router.navigateByUrl('/pin', { replaceUrl: true });
}
}
else{
@@ -141,7 +148,15 @@ export class LoginPage implements OnInit {
if(pathName) {
this.router.navigate([pathName]);
} else {
this.router.navigate(['/home/events']);
if(this.permissionService.userPermission(this.permissionList.Agenda) || this.permissionService.userPermission(this.permissionList.Gabinete)){
this.router.navigate(['/home/events']);
}
else if(this.permissionService.userPermission(this.permissionList.Chat)){
this.router.navigate(['/home/chat']);
}
else if(this.permissionService.userPermission(this.permissionList.Actions)){
this.router.navigate(['/home/publications']);
}
}
}