From 16b6b37b9481e6f04cbce226e019b8e579b95eaa Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 9 Feb 2026 11:08:00 +0500 Subject: [PATCH] web: enable password changing --- apps/web/src/dialogs/recovery-key-dialog.tsx | 2 +- .../web/src/dialogs/settings/auth-settings.ts | 64 +++++++++---------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/apps/web/src/dialogs/recovery-key-dialog.tsx b/apps/web/src/dialogs/recovery-key-dialog.tsx index 5298613ce..4491af84b 100644 --- a/apps/web/src/dialogs/recovery-key-dialog.tsx +++ b/apps/web/src/dialogs/recovery-key-dialog.tsx @@ -38,7 +38,7 @@ type RecoveryKeyDialogProps = BaseDialogProps; export const RecoveryKeyDialog = DialogManager.register( function RecoveryKeyDialog(props: RecoveryKeyDialogProps) { const key = usePromise(() => - db.user.getEncryptionKey().then((key) => key?.key) + db.user.getMasterKey().then((key) => key?.key) ); const [copyText, setCopyText] = useState("Copy to clipboard"); diff --git a/apps/web/src/dialogs/settings/auth-settings.ts b/apps/web/src/dialogs/settings/auth-settings.ts index 79e62c2fd..8166be867 100644 --- a/apps/web/src/dialogs/settings/auth-settings.ts +++ b/apps/web/src/dialogs/settings/auth-settings.ts @@ -27,7 +27,6 @@ import { RecoveryCodesDialog } from "../mfa/recovery-code-dialog"; import { MultifactorDialog } from "../mfa/multi-factor-dialog"; import { RecoveryKeyDialog } from "../recovery-key-dialog"; import { strings } from "@notesnook/intl"; -import { ConfirmDialog } from "../confirm"; export const AuthenticationSettings: SettingsGroup[] = [ { @@ -46,39 +45,38 @@ export const AuthenticationSettings: SettingsGroup[] = [ title: strings.changePassword(), variant: "secondary", action: async () => { - ConfirmDialog.show({ - title: "Password changing has been disabled temporarily", - message: - "Password changing has been disabled temporarily to address some issues faced by users. It will be enabled again once the issues have resolved.", - positiveButtonText: "Ok" + const result = await showPasswordDialog({ + title: strings.changePassword(), + message: strings.changePasswordDesc(), + inputs: { + oldPassword: { + label: strings.oldPassword(), + autoComplete: "current-password" + }, + newPassword: { + label: strings.newPassword(), + autoComplete: "new-password" + } + }, + validate: async ({ oldPassword, newPassword }) => { + try { + if (!(await createBackup({ noVerify: true }))) return false; + return ( + (await db.user.changePassword( + oldPassword, + newPassword + )) || false + ); + } catch (e) { + console.error(e); + return false; + } + } }); - return; - // const result = await showPasswordDialog({ - // title: strings.changePassword(), - // message: strings.changePasswordDesc(), - // inputs: { - // oldPassword: { - // label: strings.oldPassword(), - // autoComplete: "current-password" - // }, - // newPassword: { - // label: strings.newPassword(), - // autoComplete: "new-password" - // } - // }, - // validate: async ({ oldPassword, newPassword }) => { - // if (!(await createBackup())) return false; - // await db.user.clearSessions(); - // return ( - // (await db.user.changePassword(oldPassword, newPassword)) || - // false - // ); - // } - // }); - // if (result) { - // showToast("success", strings.passwordChangedSuccessfully()); - // await RecoveryKeyDialog.show({}); - // } + if (result) { + showToast("success", strings.passwordChangedSuccessfully()); + await RecoveryKeyDialog.show({}); + } } } ]