mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix to accept login of user that does not have access to Chat
This commit is contained in:
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { PermissionService } from '../services/permission.service';
|
||||
import { LocalstoreService } from '../store/localstore.service';
|
||||
import { SessionStore } from '../store/session.service';
|
||||
|
||||
@@ -13,6 +14,7 @@ export class AuthGuard implements CanActivate {
|
||||
private router:Router,
|
||||
private localstoreService: LocalstoreService,
|
||||
private authService: AuthService,
|
||||
public p: PermissionService,
|
||||
){}
|
||||
|
||||
canActivate(
|
||||
@@ -29,7 +31,10 @@ export class AuthGuard implements CanActivate {
|
||||
this.router.navigate(['/']);
|
||||
return false
|
||||
} else {
|
||||
this.authService.loginChat();
|
||||
if(this.p.userPermission(this.p.permissionList.Chat.access) == true){
|
||||
this.authService.loginChat();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { AlertController } from '@ionic/angular';
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-inactivity',
|
||||
@@ -31,6 +32,7 @@ export class InactivityPage implements OnInit {
|
||||
private toastService: ToastService,
|
||||
public alertController: AlertController,
|
||||
public ThemeService: ThemeService,
|
||||
public p: PermissionService,
|
||||
) {}
|
||||
|
||||
loop = false
|
||||
@@ -115,10 +117,15 @@ export class InactivityPage implements OnInit {
|
||||
|
||||
if (attempt) {
|
||||
|
||||
|
||||
// if current attemp is equal to the current user
|
||||
if (attempt.UserId == SessionStore.user.UserId) {
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
this.authService.loginChat();
|
||||
|
||||
if(this.p.userPermission(this.p.permissionList.Chat.access)){
|
||||
this.authService.loginChat();
|
||||
}
|
||||
|
||||
this.getToken();
|
||||
SessionStore.setInativity(true)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export class LoginPage implements OnInit {
|
||||
private changeProfileService: ChangeProfileService,
|
||||
public ThemeService: ThemeService,
|
||||
private storageservice: StorageService,
|
||||
public permissionService: PermissionService,
|
||||
public p: PermissionService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -104,11 +104,20 @@ 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();
|
||||
|
||||
console.log(this.p.userPermission(this.permissionList.Chat.access));
|
||||
|
||||
|
||||
if(this.p.userPermission(this.permissionList.Chat.access)){
|
||||
alert('RC IN')
|
||||
await this.authService.loginChat();
|
||||
await this.authService.loginToChatWs();
|
||||
}
|
||||
|
||||
this.getToken();
|
||||
SessionStore.setInativity(true);
|
||||
|
||||
@@ -123,8 +132,12 @@ export class LoginPage implements OnInit {
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
|
||||
this.changeProfileService.run();
|
||||
await this.authService.loginChat();
|
||||
await this.authService.loginToChatWs();
|
||||
|
||||
if(this.p.userPermission(this.permissionList.Chat.access)){
|
||||
await this.authService.loginChat();
|
||||
await this.authService.loginToChatWs();
|
||||
}
|
||||
|
||||
this.getToken();
|
||||
this.router.navigateByUrl('/pin', { replaceUrl: true });
|
||||
|
||||
@@ -148,14 +161,13 @@ export class LoginPage implements OnInit {
|
||||
if(pathName) {
|
||||
this.router.navigate([pathName]);
|
||||
} else {
|
||||
if(this.permissionService.userPermission(this.permissionList.Agenda.access) || this.permissionService.userPermission(this.permissionList.Gabinete.access)){
|
||||
if(this.p.userPermission(this.permissionList.Agenda.access) || this.p.userPermission(this.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.permissionList.Chat.access) && this.p.userPermission(this.permissionList.Actions.access)){
|
||||
this.router.navigate(['/home/chat']);
|
||||
}
|
||||
else if(this.permissionService.userPermission(this.permissionList.Actions.access)){
|
||||
alert('here')
|
||||
else if(this.p.userPermission(this.permissionList.Actions.access)){
|
||||
this.router.navigate(['/home/publications']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { RoomService } from './chat/room.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { InitialsService } from './functions/initials.service';
|
||||
import { PermissionService } from './permission.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -46,7 +47,8 @@ export class AuthService {
|
||||
private processesService: ProcessesService,
|
||||
private AttachmentsService: AttachmentsService,
|
||||
private storage: Storage,
|
||||
private initialsService: InitialsService ) {
|
||||
private initialsService: InitialsService,
|
||||
public p: PermissionService, ) {
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
|
||||
@@ -54,8 +56,10 @@ export class AuthService {
|
||||
this.ValidatedUser = SessionStore.user
|
||||
|
||||
// console.log('login', SessionStore.user.RochetChatUser, SessionStore.user.Password)
|
||||
this.loginToChatWs()
|
||||
|
||||
if(this.p.userPermission(this.p.permissionList.Chat.access) == true ){
|
||||
this.loginToChatWs()
|
||||
}
|
||||
}
|
||||
|
||||
if (localStorage.getItem("userChat") != null) {
|
||||
|
||||
Reference in New Issue
Block a user