mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-18 19:25:13 +00:00
fix(console): general fixes, project grants for owned and granted context (#425)
* update and delete project grants * fix: user grant id (#421) * fix: verboser logging on sql err (#412) * fix(eventstore): improve insert statement * fix: verbose logging on error * fix: simplify insertEvents * fix: project grant delete (#417) * fix: add grant id to user grant if needed * fix: add grant id to user grant if needed Co-authored-by: Silvan <[email protected]> * fix user grant context * lint * role validators * fix: usergrantid (#424) * fix: verboser logging on sql err (#412) * fix(eventstore): improve insert statement * fix: verbose logging on error * fix: simplify insertEvents * fix: project grant delete (#417) * fix: add grant id to user grant if needed * fix: add grant id to user grant if needed * fix: add bulk remove * fix: merge Co-authored-by: Silvan <[email protected]> Co-authored-by: Fabi <[email protected]> Co-authored-by: Silvan <[email protected]>
This commit is contained in:
co-authored by
Silvan
Fabi
parent
cf51bbc36d
commit
0b012f2fa2
@@ -35,10 +35,26 @@
|
||||
|
||||
<ng-container *ngIf="currentCreateStep === STEPS">
|
||||
<h1>{{'PROJECT.GRANT.CREATE.SEL_ROLES' | translate}}</h1>
|
||||
<ng-container *ngIf="context === UserGrantContext.OWNED_PROJECT && projectId">
|
||||
<app-card>
|
||||
<app-project-roles (changedSelection)="selectRoles($event)" [projectId]="projectId">
|
||||
</app-project-roles>
|
||||
</app-card>
|
||||
</ng-container>
|
||||
|
||||
<app-card *ngIf="projectId">
|
||||
<app-project-roles (changedSelection)="selectRoles($event)" [projectId]="projectId"></app-project-roles>
|
||||
</app-card>
|
||||
<ng-container *ngIf="context === UserGrantContext.GRANTED_PROJECT && grantRolesKeyList; else noGrantRolesFound">
|
||||
<mat-form-field class="form-field" appearance="outline">
|
||||
<mat-label>{{ 'PROJECT.GRANT.ROLENAMESLIST' | translate }}</mat-label>
|
||||
<mat-select multiple (selectionChange)="rolesList = $event.value">
|
||||
<mat-option *ngFor="let role of grantRolesKeyList" [value]="role">
|
||||
{{role}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</ng-container>
|
||||
<ng-template #noGrantRolesFound>
|
||||
<span>{{'PROJECT.GRANT.NOROLES'}}</span>
|
||||
</ng-template>
|
||||
</ng-container>
|
||||
|
||||
<div class="btn-container">
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Org } from 'src/app/proto/generated/auth_pb';
|
||||
import { ProjectGrantView, ProjectRole, ProjectView, User, UserGrant } from 'src/app/proto/generated/management_pb';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
|
||||
import { ProjectService } from 'src/app/services/project.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
@@ -31,12 +32,15 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
private subscription: Subscription = new Subscription();
|
||||
|
||||
public UserGrantContext: any = UserGrantContext;
|
||||
|
||||
public grantRolesKeyList: string[] = [];
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private userService: MgmtUserService,
|
||||
private toast: ToastService,
|
||||
private _location: Location,
|
||||
private route: ActivatedRoute,
|
||||
private projectService: ProjectService,
|
||||
) {
|
||||
this.subscription = this.route.params.subscribe((params: Params) => {
|
||||
const { context, projectid, grantid, userid } = params;
|
||||
@@ -46,12 +50,23 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
this.grantId = grantid;
|
||||
this.userId = userid;
|
||||
|
||||
if (this.userId) {
|
||||
this.context = UserGrantContext.USER;
|
||||
} else if (this.projectId && !this.grantId) {
|
||||
console.log('usergrantcreate');
|
||||
|
||||
// if (this.userId) {
|
||||
// this.context = UserGrantContext.USER;
|
||||
// } else
|
||||
|
||||
if (this.projectId && !this.grantId) {
|
||||
this.context = UserGrantContext.OWNED_PROJECT;
|
||||
} else if (this.projectId && this.grantId) {
|
||||
this.context = UserGrantContext.GRANTED_PROJECT;
|
||||
console.log(this.grantId, this.projectId);
|
||||
this.projectService.GetGrantedProjectByID(this.projectId, this.grantId).then(resp => {
|
||||
console.log(resp.toObject());
|
||||
this.grantRolesKeyList = resp.toObject().roleKeysList;
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -66,18 +81,18 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
|
||||
public addGrant(): void {
|
||||
switch (this.context) {
|
||||
case UserGrantContext.USER:
|
||||
this.userService.CreateUserGrant(
|
||||
this.projectId,
|
||||
this.userId,
|
||||
this.rolesList,
|
||||
).then((data: UserGrant) => {
|
||||
this.toast.showInfo('User Grant added');
|
||||
this.close();
|
||||
}).catch(error => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
break;
|
||||
// case UserGrantContext.USER:
|
||||
// this.userService.CreateUserGrant(
|
||||
// this.projectId,
|
||||
// this.userId,
|
||||
// this.rolesList,
|
||||
// ).then((data: UserGrant) => {
|
||||
// this.toast.showInfo('User Grant added');
|
||||
// this.close();
|
||||
// }).catch(error => {
|
||||
// this.toast.showError(error);
|
||||
// });
|
||||
// break;
|
||||
case UserGrantContext.OWNED_PROJECT:
|
||||
this.userService.CreateProjectUserGrant(
|
||||
this.projectId,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CardModule } from 'src/app/modules/card/card.module';
|
||||
import {
|
||||
@@ -24,6 +26,8 @@ import { UserGrantCreateComponent } from './user-grant-create.component';
|
||||
MatIconModule,
|
||||
TranslateModule,
|
||||
CardModule,
|
||||
MatFormFieldModule,
|
||||
MatSelectModule,
|
||||
SearchProjectAutocompleteModule,
|
||||
SearchUserAutocompleteModule,
|
||||
ProjectRolesModule,
|
||||
|
||||
Reference in New Issue
Block a user