Skip to content

Commit

Permalink
Show RBAC notification only once per account item.
Browse files Browse the repository at this point in the history
Sometimes the resource tree continously refreshes all expanded nodes
and if authentication fails the RBAC notification pops up again and again.

With this change we show the notification only once for each account node.
Refreshing the parent (resource group) node will create a new instance
and show the notification again.
  • Loading branch information
sevoku committed Jul 18, 2024
1 parent f05d010 commit a6a4935
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/docdb/tree/DocDBAccountTreeItemBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { DocDBTreeItemBase } from './DocDBTreeItemBase';
export abstract class DocDBAccountTreeItemBase extends DocDBTreeItemBase<DatabaseDefinition & Resource> {
public readonly label: string;
public readonly childTypeLabel: string = "Database";

private rBacNotificationShown: boolean = false;

constructor(
parent: AzExtParentTreeItem,
Expand Down Expand Up @@ -93,7 +93,8 @@ export abstract class DocDBAccountTreeItemBase extends DocDBTreeItemBase<Databas
try {
return await super.loadMoreChildrenImpl(clearCache, context);
} catch (e) {
if (e instanceof Error && isRbacException(e)) {
if (e instanceof Error && isRbacException(e) && !this.rBacNotificationShown) {
this.rBacNotificationShown = true;
const principalId = await getSignedInPrincipalIdForAccountEndpoint(this.root.endpoint) ?? '';
// chedck if the principal ID matches the one that is signed in, otherwise this might be a security problem, hence show the error message
if (e.message.includes(`[${principalId}]`) && await ensureRbacPermission(this, principalId, context)) {
Expand Down

0 comments on commit a6a4935

Please sign in to comment.