mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-14 01:45:12 +00:00
feat(console): authorizations from user context, add grants to auth user view, fix app saving (#895)
* user grant on project * grant in auth user, enable creation, fix inv regex * use autocomplete solutions, section for usre ctx * user grant create for user context * fix edit from table * fix create context * fix authorization to write * grant overview component * fix user grants without context * lint * turn table highlighting off, rm logs * fix app name saving * fix table refresh for project grants * translate toast * i18n * lint * Update console/src/assets/i18n/de.json Co-authored-by: Florian Forster <[email protected]> Co-authored-by: Florian Forster <[email protected]>
This commit is contained in:
co-authored by
Florian Forster
parent
afa38aa2c2
commit
78e5c26015
@@ -2,6 +2,7 @@ import { Location } from '@angular/common';
|
||||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { UserTarget } from 'src/app/modules/search-user-autocomplete/search-user-autocomplete.component';
|
||||
import { UserGrantContext } from 'src/app/modules/user-grants/user-grants-datasource';
|
||||
import { Org } from 'src/app/proto/generated/auth_pb';
|
||||
import { ProjectGrantView, ProjectRole, ProjectView, UserGrant, UserView } from 'src/app/proto/generated/management_pb';
|
||||
@@ -19,7 +20,10 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
|
||||
public org!: Org.AsObject;
|
||||
public userId: string = '';
|
||||
|
||||
public projectId: string = '';
|
||||
public project!: ProjectGrantView.AsObject | ProjectView.AsObject;
|
||||
|
||||
public grantId: string = '';
|
||||
public rolesList: string[] = [];
|
||||
|
||||
@@ -33,6 +37,12 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
public UserGrantContext: any = UserGrantContext;
|
||||
|
||||
public grantRolesKeyList: string[] = [];
|
||||
|
||||
public user!: UserView.AsObject;
|
||||
public UserTarget: any = UserTarget;
|
||||
|
||||
public ProjectGrantView: any = ProjectGrantView;
|
||||
public ProjectView: any = ProjectView;
|
||||
constructor(
|
||||
private userService: ManagementService,
|
||||
private toast: ToastService,
|
||||
@@ -42,8 +52,8 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
private mgmtService: ManagementService,
|
||||
) {
|
||||
this.subscription = this.route.params.subscribe((params: Params) => {
|
||||
const { context, projectid, grantid, userid } = params;
|
||||
this.context = context;
|
||||
const { projectid, grantid, userid } = params;
|
||||
this.context = UserGrantContext.NONE;
|
||||
|
||||
this.projectId = projectid;
|
||||
this.grantId = grantid;
|
||||
@@ -58,6 +68,14 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
}).catch((error: any) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else if (this.userId) {
|
||||
this.context = UserGrantContext.USER;
|
||||
this.mgmtService.GetUserByID(this.userId).then(resp => {
|
||||
this.user = resp.toObject();
|
||||
console.log(this.user);
|
||||
}).catch((error: any) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -97,12 +115,52 @@ export class UserGrantCreateComponent implements OnDestroy {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
break;
|
||||
case UserGrantContext.USER:
|
||||
let grantId;
|
||||
|
||||
if ((this.project as ProjectGrantView.AsObject)?.id) {
|
||||
grantId = (this.project as ProjectGrantView.AsObject).id;
|
||||
}
|
||||
|
||||
this.userService.CreateUserGrant(
|
||||
this.userId,
|
||||
this.rolesList,
|
||||
this.project.projectId,
|
||||
grantId,
|
||||
).then((data: UserGrant) => {
|
||||
this.toast.showInfo('PROJECT.GRANT.TOAST.PROJECTGRANTUSERGRANTADDED', true);
|
||||
this.close();
|
||||
}).catch((error: any) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
break;
|
||||
case UserGrantContext.NONE:
|
||||
let tempGrantId;
|
||||
|
||||
if ((this.project as ProjectGrantView.AsObject)?.id) {
|
||||
tempGrantId = (this.project as ProjectGrantView.AsObject).id;
|
||||
}
|
||||
|
||||
this.userService.CreateUserGrant(
|
||||
this.userId,
|
||||
this.rolesList,
|
||||
this.project.projectId,
|
||||
tempGrantId,
|
||||
).then((data: UserGrant) => {
|
||||
this.toast.showInfo('PROJECT.GRANT.TOAST.PROJECTGRANTUSERGRANTADDED', true);
|
||||
this.close();
|
||||
}).catch((error: any) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public selectProject(project: ProjectView.AsObject | ProjectGrantView.AsObject | any): void {
|
||||
this.project = project;
|
||||
this.projectId = project.projectId;
|
||||
this.grantRolesKeyList = project.roleKeysList ?? [];
|
||||
}
|
||||
|
||||
public selectUser(user: UserView.AsObject): void {
|
||||
|
||||
Reference in New Issue
Block a user