mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Update ChangePasswordSection.tsx
This commit is contained in:
@@ -13,6 +13,7 @@ import { Button, FormControl, Input } from "@app/components/v2";
|
||||
import { useUser } from "@app/context";
|
||||
import { useResetUserPasswordV2, useSendPasswordSetupEmail } from "@app/hooks/api/auth/queries";
|
||||
import { UserEncryptionVersion } from "@app/hooks/api/auth/types";
|
||||
import { clearSession } from "@app/hooks/api/users/queries";
|
||||
|
||||
type Errors = {
|
||||
tooShort?: string;
|
||||
@@ -61,18 +62,22 @@ export const ChangePasswordSection = () => {
|
||||
if (errorCheck) return;
|
||||
setIsLoading(true);
|
||||
|
||||
if (user.encryptionVersion === UserEncryptionVersion.V2) {
|
||||
await resetPasswordV2({
|
||||
oldPassword,
|
||||
newPassword
|
||||
});
|
||||
} else {
|
||||
if (user.encryptionVersion !== UserEncryptionVersion.V2) {
|
||||
createNotification({
|
||||
text: "Legacy encryption scheme not supported for changing password. Please log out and log back in before changing your password.",
|
||||
type: "error"
|
||||
});
|
||||
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await resetPasswordV2({
|
||||
oldPassword,
|
||||
newPassword
|
||||
});
|
||||
clearSession();
|
||||
|
||||
setIsLoading(false);
|
||||
createNotification({
|
||||
text: "Successfully changed password",
|
||||
|
||||
Reference in New Issue
Block a user