mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-30 19:12:16 +00:00
fix(console): display granted org name in authorizations and show user information (#7116)
* fix: add granted org info to user grants query response * fix: show user info, tests and add columns to user grant * fix: add check for org membership * fix: typo in find logic --------- Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
co-authored by
Max Peintner
parent
94b3799690
commit
d590da7c7d
@@ -109,7 +109,7 @@
|
||||
<ng-container matColumnDef="org">
|
||||
<th mat-header-cell *matHeaderCellDef>{{ 'PROJECT.GRANT.ORG' | translate }}</th>
|
||||
<td mat-cell *matCellDef="let grant">
|
||||
{{ grant.orgName }}
|
||||
{{ grant.grantedOrgName }}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
<i class="las la-trash"></i>
|
||||
</button>
|
||||
|
||||
<button menuActions mat-menu-item [routerLink]="['/users', grant.userId]">
|
||||
<button menuActions mat-menu-item (click)="showUser(grant)">
|
||||
{{ 'ACTIONS.TABLE.SHOWUSER' | translate: { value: grant.displayName } }}
|
||||
</button>
|
||||
</cnsl-table-actions>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { tap } from 'rxjs/operators';
|
||||
import { enterAnimations } from 'src/app/animations';
|
||||
import { UserGrant as AuthUserGrant } from 'src/app/proto/generated/zitadel/auth_pb';
|
||||
import { Role } from 'src/app/proto/generated/zitadel/project_pb';
|
||||
import { Type, UserGrant as MgmtUserGrant, UserGrantQuery } from 'src/app/proto/generated/zitadel/user_pb';
|
||||
import { Type, UserGrant as MgmtUserGrant, UserGrantQuery, UserGrant } from 'src/app/proto/generated/zitadel/user_pb';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
@@ -18,6 +18,7 @@ import { PageEvent, PaginatorComponent } from '../paginator/paginator.component'
|
||||
import { UserGrantRoleDialogComponent } from '../user-grant-role-dialog/user-grant-role-dialog.component';
|
||||
import { WarnDialogComponent } from '../warn-dialog/warn-dialog.component';
|
||||
import { UserGrantContext, UserGrantsDataSource } from './user-grants-datasource';
|
||||
import { Org, OrgState } from 'src/app/proto/generated/zitadel/org_pb';
|
||||
|
||||
export enum UserGrantListSearchKey {
|
||||
DISPLAY_NAME,
|
||||
@@ -68,6 +69,7 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
|
||||
@Input() public type: Type | undefined = undefined;
|
||||
|
||||
public filterOpen: boolean = false;
|
||||
public myOrgs: Array<Org.AsObject> = [];
|
||||
constructor(
|
||||
private authService: GrpcAuthService,
|
||||
private userService: ManagementService,
|
||||
@@ -115,6 +117,9 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
this.loadGrantsPage(this.type);
|
||||
this.authService.listMyProjectOrgs(undefined, 0).then((orgs) => {
|
||||
this.myOrgs = orgs.resultList;
|
||||
});
|
||||
}
|
||||
|
||||
public ngAfterViewInit(): void {
|
||||
@@ -300,4 +305,21 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
|
||||
this.loadGrantsPage(this.type);
|
||||
}
|
||||
}
|
||||
|
||||
public showUser(grant: UserGrant.AsObject) {
|
||||
const org: Org.AsObject = {
|
||||
id: grant.grantedOrgId,
|
||||
name: grant.grantedOrgName,
|
||||
state: OrgState.ORG_STATE_ACTIVE,
|
||||
primaryDomain: grant.grantedOrgDomain,
|
||||
};
|
||||
|
||||
// Check if user has permissions for that org before changing active org
|
||||
if (this.myOrgs.find((org) => org.id === grant.grantedOrgId)) {
|
||||
this.authService.setActiveOrg(org);
|
||||
this.router.navigate(['/users', grant.userId]);
|
||||
} else {
|
||||
this.toast.showInfo('GRANTS.TOAST.CANTSHOWINFO', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user