fix(console): user grant read check (#681)

* fix: user grant read check

* fix guard

* rm console.logs
This commit is contained in:
Max Peintner 2020-09-01 16:23:24 +02:00 committed by GitHub
parent 0dd49f7430
commit 0d44b69c0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 8 deletions

View File

@ -75,7 +75,7 @@ const routes: Routes = [
.then(m => m.UserGrantCreateModule),
canActivate: [RoleGuard],
data: {
roles: ['project.grant.user.grant.write'],
roles: ['user.grant.write'],
},
},
{

View File

@ -12,11 +12,11 @@
</div>
</div>
<ng-template appHasRole
[appHasRole]="['project.grant.user.grant.read', 'project.grant.user.grant.read:'+grantId]">
<ng-template appHasRole [appHasRole]="['user.grant.read', 'user.grant.read:'+grantId]">
<app-card *ngIf="project?.projectId" title="{{ 'GRANTS.PROJECT.TITLE' | translate }}"
description="{{'GRANTS.PROJECT.DESCRIPTION' | translate }}">
<app-user-grants [context]="userGrantContext" [projectId]="projectId" [grantId]="grantId"
<app-user-grants *ngIf="projectId && grantId" [context]="UserGrantContext.GRANTED_PROJECT"
[projectId]="projectId" [grantId]="grantId"
[displayedColumns]="['select','user', 'projectId', 'creationDate', 'changeDate', 'roleNamesList']"
[allowCreate]="['user.grant.write','user.grant.write:'+grantId] | hasRole | async"
[allowDelete]="['user.grant.delete','user.grant.delete:'+grantId] | hasRole | async">

View File

@ -63,7 +63,7 @@ export class GrantedProjectDetailComponent implements OnInit, OnDestroy {
public isZitadel: boolean = false;
public userGrantContext: UserGrantContext = UserGrantContext.GRANTED_PROJECT;
UserGrantContext: any = UserGrantContext;
public userGrantSearchKey: UserGrantSearchKey = UserGrantSearchKey.USERGRANTSEARCHKEY_PROJECT_ID;
// members

View File

@ -88,7 +88,7 @@
<ng-template appHasRole [appHasRole]="['user.grant.read']">
<app-card *ngIf="project?.projectId" title="{{ 'GRANTS.PROJECT.TITLE' | translate }}"
description="{{'GRANTS.PROJECT.DESCRIPTION' | translate }}">
<app-user-grants [context]="userGrantContext" [projectId]="projectId"
<app-user-grants [context]="UserGrantContext.OWNED_PROJECT" [projectId]="projectId"
[allowCreate]="(['user.grant.write', 'user.grant.write:'+projectId] | hasRole) | async"
[allowDelete]="(['user.grant.delete','user.grant.delete:'+projectId] | hasRole) | async">
</app-user-grants>

View File

@ -65,7 +65,7 @@ export class OwnedProjectDetailComponent implements OnInit, OnDestroy {
public isZitadel: boolean = false;
public userGrantSearchKey: UserGrantSearchKey = UserGrantSearchKey.USERGRANTSEARCHKEY_PROJECT_ID;
public userGrantContext: UserGrantContext = UserGrantContext.OWNED_PROJECT;
public UserGrantContext: any = UserGrantContext;
// members
public totalMemberResult: number = 0;

View File

@ -141,7 +141,7 @@ export class GrpcAuthService {
public hasRoles(userRoles: string[], requestedRoles: string[] | RegExp[]): boolean {
return requestedRoles.findIndex((regexp: any) => {
return userRoles.findIndex(role => {
return (new RegExp(regexp)).test(role);
return new RegExp(regexp).test(role);
}) > -1;
}) > -1;
}