Skip to content

Commit

Permalink
web: create backup before changing password
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Mar 5, 2024
1 parent d5adc3b commit af7120e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion apps/web/src/dialogs/password-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ function PasswordDialog(props) {
loading: isLoading,
disabled: isLoading
}}
negativeButton={{ text: "Cancel", onClick: () => props.onClose(false) }}
negativeButton={{
text: "Cancel",
onClick: () => props.onClose(false),
disabled: isLoading
}}
>
<Box
id="passwordForm"
Expand Down
16 changes: 10 additions & 6 deletions apps/web/src/dialogs/settings/auth-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

import { SettingsGroup } from "./types";
import { useStore as useUserStore } from "../../stores/user-store";
import { verifyAccount } from "../../common";
import { createBackup, verifyAccount } from "../../common";
import {
show2FARecoveryCodesDialog,
showMultifactorDialog,
showPasswordDialog
showPasswordDialog,
showRecoveryKeyDialog
} from "../../common/dialog-controller";
import { db } from "../../common/db";
import { showToast } from "../../utils/toast";
Expand All @@ -45,19 +46,22 @@ export const AuthenticationSettings: SettingsGroup[] = [
title: "Change password",
variant: "secondary",
action: async () => {
await createBackup();
const result = await showPasswordDialog(
"change_account_password",
async (data) => {
await db.user?.clearSessions();
return (
db.user?.changePassword(
(await db.user?.changePassword(
data.oldPassword,
data.newPassword
) || false
)) || false
);
}
);
if (result) showToast("success", "Account password changed!");
if (result) {
showToast("success", "Account password changed!");
await showRecoveryKeyDialog();
}
}
}
]
Expand Down

0 comments on commit af7120e

Please sign in to comment.