This commit is contained in:
Peter Maquiran
2022-04-07 14:24:07 +01:00
parent 34580da026
commit e8ffcca028
10 changed files with 83 additions and 14 deletions
+3 -1
View File
@@ -132,6 +132,8 @@ export class AuthService {
return true;
}
this.initialsService.getInitials(session.FullName);
}
//Login to rocketChat server2
@@ -298,8 +300,8 @@ export class AuthService {
this.userData$.next('');
this.router.navigate(['']);
}) */
}
async presentAlert(message: string) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
+10 -5
View File
@@ -6,6 +6,7 @@ import { StorageService } from './storage.service';
import { HttpClient, HttpHeaderResponse } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { Storage } from '@ionic/storage';
import { PermissionService } from './permission.service';
@Injectable({
@@ -29,15 +30,19 @@ export class ChatService {
private authService: AuthService,
private storage: Storage,
private storageService:StorageService,
public p: PermissionService,
)
{
this.loggedUserChat = authService.ValidatedUserChat;
this.headers = new HttpHeaders();
this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId);
this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
this.options = {
headers: this.headers,
};
if(this.p.userPermission(this.p.permissionList.Chat.access)) {
this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId);
this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
this.options = {
headers: this.headers,
};
}
}
+17
View File
@@ -35,6 +35,23 @@ export class PermissionService {
return false;
}
userPermissionCount(args) {
if(!Array.isArray(args)) {
args = [args]
}
let count = 0
for(let permission of (this.SessionStore.user.UserPermissions || [])) {
if (args.includes(permission)) {
count++;
}
}
return count;
}
role(args: any) {
let UserRoleIsValid = this.userRole(args)