mirror of
https://github.com/halo-dev/halo.git
synced 2025-12-20 16:44:38 +08:00
Refine password validation
This commit is contained in:
@@ -12,6 +12,7 @@ import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
|
||||
import { setFocus } from "@/formkit/utils/focus";
|
||||
import { useQueryClient } from "@tanstack/vue-query";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { PASSWORD_REGEX } from "@/constants/regex";
|
||||
|
||||
const { t } = useI18n();
|
||||
const queryClient = useQueryClient();
|
||||
@@ -112,9 +113,13 @@ const handleCreateUser = async () => {
|
||||
:label="$t('core.user.change_password_modal.fields.new_password.label')"
|
||||
type="password"
|
||||
name="password"
|
||||
validation="required:trim|length:5,100|matches:/^\S.*\S$/"
|
||||
:validation="[
|
||||
['required'],
|
||||
['length', 5, 257],
|
||||
['matches', PASSWORD_REGEX],
|
||||
]"
|
||||
:validation-messages="{
|
||||
matches: $t('core.formkit.validation.trim'),
|
||||
matches: $t('core.formkit.validation.password'),
|
||||
}"
|
||||
></FormKit>
|
||||
<FormKit
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||
import { PASSWORD_REGEX } from "@/constants/regex";
|
||||
import { setFocus } from "@/formkit/utils/focus";
|
||||
import type { User } 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')"
|
||||
name="password"
|
||||
type="password"
|
||||
validation="required:trim|length:5,100|matches:/^\S.*\S$/"
|
||||
:validation="[
|
||||
['required'],
|
||||
['length', 5, 257],
|
||||
['matches', PASSWORD_REGEX],
|
||||
]"
|
||||
:validation-messages="{
|
||||
matches: $t('core.formkit.validation.trim'),
|
||||
matches: $t('core.formkit.validation.password'),
|
||||
}"
|
||||
></FormKit>
|
||||
<FormKit
|
||||
@@ -92,10 +97,7 @@ const handleChangePassword = async () => {
|
||||
"
|
||||
name="password_confirm"
|
||||
type="password"
|
||||
validation="confirm|required:trim|length:5,100|matches:/^\S.*\S$/"
|
||||
:validation-messages="{
|
||||
matches: $t('core.formkit.validation.trim'),
|
||||
}"
|
||||
validation="confirm|required"
|
||||
></FormKit>
|
||||
</FormKit>
|
||||
<template #footer>
|
||||
|
||||
Reference in New Issue
Block a user