@@ -27,7 +27,6 @@ import { RecoveryCodesDialog } from "../mfa/recovery-code-dialog";
2727import { MultifactorDialog } from "../mfa/multi-factor-dialog" ;
2828import { RecoveryKeyDialog } from "../recovery-key-dialog" ;
2929import { strings } from "@notesnook/intl" ;
30- import { ConfirmDialog } from "../confirm" ;
3130
3231export 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