mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
add permission logic to nav bar.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PermissionService } from './worker/permission.service';
|
||||
import { PermissionService } from './permission.service';
|
||||
|
||||
describe('PermissionService', () => {
|
||||
let service: PermissionService;
|
||||
|
||||
+19
-5
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SessionStore } from '../../store/session.service';
|
||||
import { SessionStore } from '../store/session.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -15,12 +15,26 @@ export class PermissionService {
|
||||
if(!Array.isArray(args)) {
|
||||
args = [args]
|
||||
}
|
||||
|
||||
return args.includes(this.SessionStore.user.Profile)
|
||||
|
||||
return args.includes(this.SessionStore.user.Profile)
|
||||
}
|
||||
|
||||
userPermission(args) {
|
||||
|
||||
if(!Array.isArray(args)) {
|
||||
args = [args]
|
||||
}
|
||||
for(let permission of this.SessionStore.user.UserPermissions){
|
||||
if (args.includes(permission)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
role(args: any) {
|
||||
|
||||
|
||||
let UserRoleIsValid = this.userRole(args)
|
||||
|
||||
return {
|
||||
@@ -39,4 +53,4 @@ export class PermissionService {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AttachmentsService } from '../attachments.service';
|
||||
import { EventsService } from '../events.service';
|
||||
import { PermissionService } from '../worker/permission.service';
|
||||
import { PermissionService } from '../permission.service';
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class EventService {
|
||||
|
||||
|
||||
create({body, calendar}) {
|
||||
|
||||
|
||||
|
||||
if(this.p.userRole(['PR'])) {
|
||||
return this.eventService.postEventPr(body, calendar)
|
||||
|
||||
Reference in New Issue
Block a user