mirror of https://github.com/halo-dev/halo
Refine password validation
parent
d6df340fe4
commit
d7aba83485
|
@ -12,6 +12,7 @@ import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
|
||||||
import { setFocus } from "@/formkit/utils/focus";
|
import { setFocus } from "@/formkit/utils/focus";
|
||||||
import { useQueryClient } from "@tanstack/vue-query";
|
import { useQueryClient } from "@tanstack/vue-query";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { PASSWORD_REGEX } from "@/constants/regex";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
@ -112,9 +113,13 @@ const handleCreateUser = async () => {
|
||||||
:label="$t('core.user.change_password_modal.fields.new_password.label')"
|
:label="$t('core.user.change_password_modal.fields.new_password.label')"
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
validation="required:trim|length:5,100|matches:/^\S.*\S$/"
|
:validation="[
|
||||||
|
['required'],
|
||||||
|
['length', 5, 257],
|
||||||
|
['matches', PASSWORD_REGEX],
|
||||||
|
]"
|
||||||
:validation-messages="{
|
:validation-messages="{
|
||||||
matches: $t('core.formkit.validation.trim'),
|
matches: $t('core.formkit.validation.password'),
|
||||||
}"
|
}"
|
||||||
></FormKit>
|
></FormKit>
|
||||||
<FormKit
|
<FormKit
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||||
|
import { PASSWORD_REGEX } from "@/constants/regex";
|
||||||
import { setFocus } from "@/formkit/utils/focus";
|
import { setFocus } from "@/formkit/utils/focus";
|
||||||
import type { User } from "@halo-dev/api-client";
|
import type { User } from "@halo-dev/api-client";
|
||||||
import { consoleApiClient } from "@halo-dev/api-client";
|
import { consoleApiClient } from "@halo-dev/api-client";
|
||||||
|
@ -81,9 +82,13 @@ const handleChangePassword = async () => {
|
||||||
:label="$t('core.user.change_password_modal.fields.new_password.label')"
|
:label="$t('core.user.change_password_modal.fields.new_password.label')"
|
||||||
name="password"
|
name="password"
|
||||||
type="password"
|
type="password"
|
||||||
validation="required:trim|length:5,100|matches:/^\S.*\S$/"
|
:validation="[
|
||||||
|
['required'],
|
||||||
|
['length', 5, 257],
|
||||||
|
['matches', PASSWORD_REGEX],
|
||||||
|
]"
|
||||||
:validation-messages="{
|
:validation-messages="{
|
||||||
matches: $t('core.formkit.validation.trim'),
|
matches: $t('core.formkit.validation.password'),
|
||||||
}"
|
}"
|
||||||
></FormKit>
|
></FormKit>
|
||||||
<FormKit
|
<FormKit
|
||||||
|
@ -92,10 +97,7 @@ const handleChangePassword = async () => {
|
||||||
"
|
"
|
||||||
name="password_confirm"
|
name="password_confirm"
|
||||||
type="password"
|
type="password"
|
||||||
validation="confirm|required:trim|length:5,100|matches:/^\S.*\S$/"
|
validation="confirm|required"
|
||||||
:validation-messages="{
|
|
||||||
matches: $t('core.formkit.validation.trim'),
|
|
||||||
}"
|
|
||||||
></FormKit>
|
></FormKit>
|
||||||
</FormKit>
|
</FormKit>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export const PASSWORD_REGEX = /^[A-Za-z0-9!@#$%^&*]+$/;
|
|
@ -1664,6 +1664,7 @@ core:
|
||||||
creation_label: Create {text} tag
|
creation_label: Create {text} tag
|
||||||
validation:
|
validation:
|
||||||
trim: Please remove the leading and trailing spaces
|
trim: Please remove the leading and trailing spaces
|
||||||
|
password: "The password can only use uppercase and lowercase letters (A-Z, a-z), numbers (0-9), and the following special characters: !{'@'}#$%^&*"
|
||||||
verification_form:
|
verification_form:
|
||||||
no_action_defined: "{label} interface not defined"
|
no_action_defined: "{label} interface not defined"
|
||||||
verify_success: "{label} successful"
|
verify_success: "{label} successful"
|
||||||
|
|
|
@ -1557,6 +1557,7 @@ core:
|
||||||
creation_label: 创建 {text} 标签
|
creation_label: 创建 {text} 标签
|
||||||
validation:
|
validation:
|
||||||
trim: 不能以空格开头或结尾
|
trim: 不能以空格开头或结尾
|
||||||
|
password: "密码只能使用大小写字母 (A-Z, a-z)、数字 (0-9),以及以下特殊字符: !{'@'}#$%^&*"
|
||||||
verification_form:
|
verification_form:
|
||||||
no_action_defined: 未定义{label}接口
|
no_action_defined: 未定义{label}接口
|
||||||
verify_success: "{label}成功"
|
verify_success: "{label}成功"
|
||||||
|
|
|
@ -1535,6 +1535,7 @@ core:
|
||||||
creation_label: 創建 {text} 標籤
|
creation_label: 創建 {text} 標籤
|
||||||
validation:
|
validation:
|
||||||
trim: 不能以空格開頭或結尾
|
trim: 不能以空格開頭或結尾
|
||||||
|
password: "密碼只能使用大小寫字母 (A-Z, a-z)、數字 (0-9),以及以下特殊字符: !{'@'}#$%^&*"
|
||||||
verification_form:
|
verification_form:
|
||||||
no_action_defined: 未定義{label}介面
|
no_action_defined: 未定義{label}介面
|
||||||
verify_success: "{label}成功"
|
verify_success: "{label}成功"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||||
|
import { PASSWORD_REGEX } from "@/constants/regex";
|
||||||
import { setFocus } from "@/formkit/utils/focus";
|
import { setFocus } from "@/formkit/utils/focus";
|
||||||
import { consoleApiClient } from "@halo-dev/api-client";
|
import { consoleApiClient } from "@halo-dev/api-client";
|
||||||
import { VButton, VModal, VSpace } from "@halo-dev/components";
|
import { VButton, VModal, VSpace } from "@halo-dev/components";
|
||||||
|
@ -81,9 +82,13 @@ const handleChangePassword = async () => {
|
||||||
"
|
"
|
||||||
name="password"
|
name="password"
|
||||||
type="password"
|
type="password"
|
||||||
validation="required:trim|length:5,100|matches:/^\S.*\S$/"
|
:validation="[
|
||||||
|
['required'],
|
||||||
|
['length', 5, 257],
|
||||||
|
['matches', PASSWORD_REGEX],
|
||||||
|
]"
|
||||||
:validation-messages="{
|
:validation-messages="{
|
||||||
matches: $t('core.formkit.validation.trim'),
|
matches: $t('core.formkit.validation.password'),
|
||||||
}"
|
}"
|
||||||
></FormKit>
|
></FormKit>
|
||||||
<FormKit
|
<FormKit
|
||||||
|
@ -94,10 +99,7 @@ const handleChangePassword = async () => {
|
||||||
"
|
"
|
||||||
name="password_confirm"
|
name="password_confirm"
|
||||||
type="password"
|
type="password"
|
||||||
validation="confirm|required:trim|length:5,100|matches:/^\S.*\S$/"
|
validation="confirm|required"
|
||||||
:validation-messages="{
|
|
||||||
matches: $t('core.formkit.validation.trim'),
|
|
||||||
}"
|
|
||||||
></FormKit>
|
></FormKit>
|
||||||
</FormKit>
|
</FormKit>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
|
Loading…
Reference in New Issue