mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-19 23:34:22 +01:00
feat: must be a new password to encrypt
This commit is contained in:
@@ -345,7 +345,9 @@ export default {
|
|||||||
confirm_password_placeholder: "Enter the same password",
|
confirm_password_placeholder: "Enter the same password",
|
||||||
encrypt: "Encrypt",
|
encrypt: "Encrypt",
|
||||||
skip: "Skip",
|
skip: "Skip",
|
||||||
error_match: "Passwords do not match"
|
error_match: "Passwords do not match",
|
||||||
|
error_same_as_existingpassword:
|
||||||
|
"New password must not match existing password"
|
||||||
},
|
},
|
||||||
decrypt: {
|
decrypt: {
|
||||||
title: "Enter your password",
|
title: "Enter your password",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createForm } from "@modular-forms/solid";
|
import { createForm } from "@modular-forms/solid";
|
||||||
import { createSignal, Show } from "solid-js";
|
import { createMemo, createSignal, Show } from "solid-js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BackLink,
|
BackLink,
|
||||||
@@ -31,7 +31,7 @@ export default function Encrypt() {
|
|||||||
const [error, setError] = createSignal<Error>();
|
const [error, setError] = createSignal<Error>();
|
||||||
const [loading, setLoading] = createSignal(false);
|
const [loading, setLoading] = createSignal(false);
|
||||||
|
|
||||||
const [_encryptPasswordForm, { Form, Field }] =
|
const [encryptPasswordForm, { Form, Field }] =
|
||||||
createForm<EncryptPasswordForm>({
|
createForm<EncryptPasswordForm>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
existingPassword: "",
|
existingPassword: "",
|
||||||
@@ -39,11 +39,16 @@ export default function Encrypt() {
|
|||||||
confirmPassword: ""
|
confirmPassword: ""
|
||||||
},
|
},
|
||||||
validate: (values) => {
|
validate: (values) => {
|
||||||
|
setError(undefined);
|
||||||
const errors: Record<string, string> = {};
|
const errors: Record<string, string> = {};
|
||||||
if (values.password !== values.confirmPassword) {
|
if (values.password !== values.confirmPassword) {
|
||||||
errors.confirmPassword = i18n.t(
|
errors.confirmPassword = i18n.t(
|
||||||
"settings.encrypt.error_match"
|
"settings.encrypt.error_match"
|
||||||
);
|
);
|
||||||
|
} else if (values.password === values.existingPassword) {
|
||||||
|
errors.password = i18n.t(
|
||||||
|
"settings.encrypt.error_same_as_existingpassword"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
@@ -66,6 +71,14 @@ export default function Encrypt() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const encryptButtonDisabled = createMemo(() => {
|
||||||
|
return (
|
||||||
|
!encryptPasswordForm.dirty ||
|
||||||
|
encryptPasswordForm.invalid ||
|
||||||
|
!!error()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MutinyWalletGuard>
|
<MutinyWalletGuard>
|
||||||
<SafeArea>
|
<SafeArea>
|
||||||
@@ -145,7 +158,11 @@ export default function Encrypt() {
|
|||||||
</InfoBox>
|
</InfoBox>
|
||||||
</Show>
|
</Show>
|
||||||
<div />
|
<div />
|
||||||
<Button intent="blue" loading={loading()}>
|
<Button
|
||||||
|
intent="blue"
|
||||||
|
disabled={encryptButtonDisabled()}
|
||||||
|
loading={loading()}
|
||||||
|
>
|
||||||
{i18n.t("settings.encrypt.encrypt")}
|
{i18n.t("settings.encrypt.encrypt")}
|
||||||
</Button>
|
</Button>
|
||||||
</VStack>
|
</VStack>
|
||||||
|
|||||||
Reference in New Issue
Block a user