mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
PM-20514 do not allow users without edit permissions to edit a cipher in notification bar (#14521)
* PM-20514 add edit check and error out of update password early * pass error
This commit is contained in:
@@ -737,8 +737,10 @@ export default class NotificationBackground {
|
|||||||
const cipher = await this.cipherService.encrypt(cipherView, userId);
|
const cipher = await this.cipherService.encrypt(cipherView, userId);
|
||||||
|
|
||||||
const shouldGetTasks = await this.getNotificationFlag();
|
const shouldGetTasks = await this.getNotificationFlag();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!cipherView.edit) {
|
||||||
|
throw new Error("You do not have permission to edit this cipher.");
|
||||||
|
}
|
||||||
const tasks = shouldGetTasks ? await this.getSecurityTasks(userId) : [];
|
const tasks = shouldGetTasks ? await this.getSecurityTasks(userId) : [];
|
||||||
const updatedCipherTask = tasks.find((task) => task.cipherId === cipherView?.id);
|
const updatedCipherTask = tasks.find((task) => task.cipherId === cipherView?.id);
|
||||||
const cipherHasTask = !!updatedCipherTask?.id;
|
const cipherHasTask = !!updatedCipherTask?.id;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export type NotificationConfirmationBodyProps = {
|
|||||||
messageDetails?: string;
|
messageDetails?: string;
|
||||||
tasksAreComplete?: boolean;
|
tasksAreComplete?: boolean;
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
handleOpenVault: () => void;
|
handleOpenVault: (e: Event) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function NotificationConfirmationBody({
|
export function NotificationConfirmationBody({
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { NotificationConfirmationFooter } from "./footer";
|
|||||||
|
|
||||||
export type NotificationConfirmationContainerProps = NotificationBarIframeInitData & {
|
export type NotificationConfirmationContainerProps = NotificationBarIframeInitData & {
|
||||||
handleCloseNotification: (e: Event) => void;
|
handleCloseNotification: (e: Event) => void;
|
||||||
handleOpenVault: () => void;
|
handleOpenVault: (e: Event) => void;
|
||||||
handleOpenTasks: (e: Event) => void;
|
handleOpenTasks: (e: Event) => void;
|
||||||
} & {
|
} & {
|
||||||
error?: string;
|
error?: string;
|
||||||
@@ -75,8 +75,10 @@ export function NotificationConfirmationContainer({
|
|||||||
buttonAria,
|
buttonAria,
|
||||||
buttonText,
|
buttonText,
|
||||||
confirmationMessage,
|
confirmationMessage,
|
||||||
tasksAreComplete,
|
error,
|
||||||
|
itemName,
|
||||||
messageDetails,
|
messageDetails,
|
||||||
|
tasksAreComplete,
|
||||||
theme,
|
theme,
|
||||||
handleOpenVault,
|
handleOpenVault,
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export type NotificationConfirmationMessageProps = {
|
|||||||
buttonText?: string;
|
buttonText?: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
messageDetails?: string;
|
messageDetails?: string;
|
||||||
handleClick: () => void;
|
handleClick: (e: Event) => void;
|
||||||
theme: Theme;
|
theme: Theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ export function NotificationConfirmationMessage({
|
|||||||
title=${buttonText}
|
title=${buttonText}
|
||||||
class=${notificationConfirmationButtonTextStyles(theme)}
|
class=${notificationConfirmationButtonTextStyles(theme)}
|
||||||
@click=${handleClick}
|
@click=${handleClick}
|
||||||
@keydown=${(e: KeyboardEvent) => handleButtonKeyDown(e, handleClick)}
|
@keydown=${(e: KeyboardEvent) => handleButtonKeyDown(e, () => handleClick(e))}
|
||||||
aria-label=${buttonAria}
|
aria-label=${buttonAria}
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
role="button"
|
role="button"
|
||||||
|
|||||||
@@ -417,7 +417,8 @@ function handleSaveCipherConfirmation(message: NotificationBarWindowMessage) {
|
|||||||
error,
|
error,
|
||||||
itemName: itemName ?? i18n.typeLogin,
|
itemName: itemName ?? i18n.typeLogin,
|
||||||
task,
|
task,
|
||||||
handleOpenVault: () => cipherId && openViewVaultItemPopout(cipherId),
|
handleOpenVault: (e: Event) =>
|
||||||
|
cipherId ? openViewVaultItemPopout(cipherId) : openAddEditVaultItemPopout(e, {}),
|
||||||
handleOpenTasks: () => sendPlatformMessage({ command: "bgOpenAtRisksPasswords" }),
|
handleOpenTasks: () => sendPlatformMessage({ command: "bgOpenAtRisksPasswords" }),
|
||||||
}),
|
}),
|
||||||
document.body,
|
document.body,
|
||||||
|
|||||||
Reference in New Issue
Block a user