Update ChangePasswordSection.tsx

This commit is contained in:
Daniel Hougaard
2025-08-05 22:05:31 +04:00
parent d924a4bccc
commit 33fe11e0fd
@@ -13,6 +13,7 @@ import { Button, FormControl, Input } from "@app/components/v2";
import { useUser } from "@app/context"; import { useUser } from "@app/context";
import { useResetUserPasswordV2, useSendPasswordSetupEmail } from "@app/hooks/api/auth/queries"; import { useResetUserPasswordV2, useSendPasswordSetupEmail } from "@app/hooks/api/auth/queries";
import { UserEncryptionVersion } from "@app/hooks/api/auth/types"; import { UserEncryptionVersion } from "@app/hooks/api/auth/types";
import { clearSession } from "@app/hooks/api/users/queries";
type Errors = { type Errors = {
tooShort?: string; tooShort?: string;
@@ -61,18 +62,22 @@ export const ChangePasswordSection = () => {
if (errorCheck) return; if (errorCheck) return;
setIsLoading(true); setIsLoading(true);
if (user.encryptionVersion === UserEncryptionVersion.V2) { if (user.encryptionVersion !== UserEncryptionVersion.V2) {
await resetPasswordV2({
oldPassword,
newPassword
});
} else {
createNotification({ createNotification({
text: "Legacy encryption scheme not supported for changing password. Please log out and log back in before changing your password.", text: "Legacy encryption scheme not supported for changing password. Please log out and log back in before changing your password.",
type: "error" type: "error"
}); });
setIsLoading(false);
return;
} }
await resetPasswordV2({
oldPassword,
newPassword
});
clearSession();
setIsLoading(false); setIsLoading(false);
createNotification({ createNotification({
text: "Successfully changed password", text: "Successfully changed password",