mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 08:27:53 +00:00
Update ChangePasswordSection.tsx
This commit is contained in:
+11
-6
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user