mirror of https://github.com/abpframework/abp.git
2 changed files with 35 additions and 0 deletions
@ -1 +1,2 @@ |
|||||
|
export * from './mock-permission.service'; |
||||
export * from './mock-rest.service'; |
export * from './mock-rest.service'; |
||||
|
|||||
@ -0,0 +1,34 @@ |
|||||
|
import { ConfigStateService, PermissionService } from '@abp/ng.core'; |
||||
|
import { Injectable } from '@angular/core'; |
||||
|
|
||||
|
@Injectable({ |
||||
|
providedIn: 'root', |
||||
|
}) |
||||
|
export class MockPermissionService extends PermissionService { |
||||
|
constructor(protected configState: ConfigStateService) { |
||||
|
super(configState); |
||||
|
this.grantAllPolicies(); |
||||
|
} |
||||
|
|
||||
|
grantAllPolicies() { |
||||
|
const grantedPolicies = new Proxy( |
||||
|
{}, |
||||
|
{ |
||||
|
get() { |
||||
|
return true; |
||||
|
}, |
||||
|
}, |
||||
|
); |
||||
|
|
||||
|
this.configState['store'].deepPatch({ auth: { grantedPolicies } }); |
||||
|
} |
||||
|
|
||||
|
grantPolicies(keys: string[]) { |
||||
|
const grantedPolicies = keys.reduce((policies, key) => { |
||||
|
policies[key] = true; |
||||
|
return policies; |
||||
|
}, {}); |
||||
|
|
||||
|
this.configState['store'].deepPatch({ auth: { grantedPolicies } }); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue