mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-01 13:10:44 -03:00
implemente un filtro usando el mismo regex que fran en el back
This commit is contained in:
@@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
let coinsidenLasPass = $derived(repetirContraseña == dto.password);
|
let coinsidenLasPass = $derived(repetirContraseña == dto.password);
|
||||||
|
|
||||||
|
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9])[A-Za-z\d\W_]*$/;
|
||||||
|
let esContraseñaValida = $derived(passwordRegex.test(dto.password));
|
||||||
|
|
||||||
async function checkUsuario() {
|
async function checkUsuario() {
|
||||||
checkeandoUsuario = true;
|
checkeandoUsuario = true;
|
||||||
esUsuarioValido = await checkUsername(dto.username);
|
esUsuarioValido = await checkUsername(dto.username);
|
||||||
@@ -45,6 +48,7 @@
|
|||||||
const handleSubmit = async (e: SubmitEvent) => {
|
const handleSubmit = async (e: SubmitEvent) => {
|
||||||
if (esUsuarioValido == false) return;
|
if (esUsuarioValido == false) return;
|
||||||
if (!coinsidenLasPass) return;
|
if (!coinsidenLasPass) return;
|
||||||
|
if (!esContraseñaValida) return;
|
||||||
|
|
||||||
cargando = true;
|
cargando = true;
|
||||||
await register(e, dto, setAlert);
|
await register(e, dto, setAlert);
|
||||||
@@ -112,8 +116,17 @@
|
|||||||
</Field.Field>
|
</Field.Field>
|
||||||
<Field.Field>
|
<Field.Field>
|
||||||
<Field.Label for="password">Contraseña</Field.Label>
|
<Field.Label for="password">Contraseña</Field.Label>
|
||||||
<Input id="password" type="password" bind:value={dto.password} required />
|
<Input
|
||||||
<Field.Description>Debe de tener por lo menos 8 caracteres.</Field.Description>
|
id="password"
|
||||||
|
type="password"
|
||||||
|
bind:value={dto.password}
|
||||||
|
required
|
||||||
|
class={{ 'border-red-500': dto.password && !esContraseñaValida }}
|
||||||
|
/>
|
||||||
|
<Field.Description
|
||||||
|
>Debe de tener por lo menos 8 caracteres, una minúscula, una mayúscula, un número y un
|
||||||
|
carácter especial.</Field.Description
|
||||||
|
>
|
||||||
</Field.Field>
|
</Field.Field>
|
||||||
<Field.Field>
|
<Field.Field>
|
||||||
<Field.Label for="confirm-password">Confirmar Contraseña</Field.Label>
|
<Field.Label for="confirm-password">Confirmar Contraseña</Field.Label>
|
||||||
@@ -128,7 +141,7 @@
|
|||||||
</Field.Field>
|
</Field.Field>
|
||||||
<Field.Group>
|
<Field.Group>
|
||||||
<Field.Field>
|
<Field.Field>
|
||||||
<Button type="submit" disabled={cargando || !coinsidenLasPass}>
|
<Button type="submit" disabled={cargando || !coinsidenLasPass || !esContraseñaValida}>
|
||||||
{#if cargando}
|
{#if cargando}
|
||||||
Creando Cuenta...
|
Creando Cuenta...
|
||||||
<Loader2Icon class="animate-spin" />
|
<Loader2Icon class="animate-spin" />
|
||||||
|
|||||||
Reference in New Issue
Block a user