Skip to content

Commit 16b6b37

Browse files
committed
web: enable password changing
1 parent 8c766ef commit 16b6b37

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

apps/web/src/dialogs/recovery-key-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type RecoveryKeyDialogProps = BaseDialogProps<false>;
3838
export const RecoveryKeyDialog = DialogManager.register(
3939
function RecoveryKeyDialog(props: RecoveryKeyDialogProps) {
4040
const key = usePromise(() =>
41-
db.user.getEncryptionKey().then((key) => key?.key)
41+
db.user.getMasterKey().then((key) => key?.key)
4242
);
4343
const [copyText, setCopyText] = useState("Copy to clipboard");
4444

apps/web/src/dialogs/settings/auth-settings.ts

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { RecoveryCodesDialog } from "../mfa/recovery-code-dialog";
2727
import { MultifactorDialog } from "../mfa/multi-factor-dialog";
2828
import { RecoveryKeyDialog } from "../recovery-key-dialog";
2929
import { strings } from "@notesnook/intl";
30-
import { ConfirmDialog } from "../confirm";
3130

3231
export const AuthenticationSettings: SettingsGroup[] = [
3332
{
@@ -46,39 +45,38 @@ export const AuthenticationSettings: SettingsGroup[] = [
4645
title: strings.changePassword(),
4746
variant: "secondary",
4847
action: async () => {
49-
ConfirmDialog.show({
50-
title: "Password changing has been disabled temporarily",
51-
message:
52-
"Password changing has been disabled temporarily to address some issues faced by users. It will be enabled again once the issues have resolved.",
53-
positiveButtonText: "Ok"
48+
const result = await showPasswordDialog({
49+
title: strings.changePassword(),
50+
message: strings.changePasswordDesc(),
51+
inputs: {
52+
oldPassword: {
53+
label: strings.oldPassword(),
54+
autoComplete: "current-password"
55+
},
56+
newPassword: {
57+
label: strings.newPassword(),
58+
autoComplete: "new-password"
59+
}
60+
},
61+
validate: async ({ oldPassword, newPassword }) => {
62+
try {
63+
if (!(await createBackup({ noVerify: true }))) return false;
64+
return (
65+
(await db.user.changePassword(
66+
oldPassword,
67+
newPassword
68+
)) || false
69+
);
70+
} catch (e) {
71+
console.error(e);
72+
return false;
73+
}
74+
}
5475
});
55-
return;
56-
// const result = await showPasswordDialog({
57-
// title: strings.changePassword(),
58-
// message: strings.changePasswordDesc(),
59-
// inputs: {
60-
// oldPassword: {
61-
// label: strings.oldPassword(),
62-
// autoComplete: "current-password"
63-
// },
64-
// newPassword: {
65-
// label: strings.newPassword(),
66-
// autoComplete: "new-password"
67-
// }
68-
// },
69-
// validate: async ({ oldPassword, newPassword }) => {
70-
// if (!(await createBackup())) return false;
71-
// await db.user.clearSessions();
72-
// return (
73-
// (await db.user.changePassword(oldPassword, newPassword)) ||
74-
// false
75-
// );
76-
// }
77-
// });
78-
// if (result) {
79-
// showToast("success", strings.passwordChangedSuccessfully());
80-
// await RecoveryKeyDialog.show({});
81-
// }
76+
if (result) {
77+
showToast("success", strings.passwordChangedSuccessfully());
78+
await RecoveryKeyDialog.show({});
79+
}
8280
}
8381
}
8482
]

0 commit comments

Comments
 (0)