feat: add Auth.js authentication with email verification and login/register forms
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5c9aa0be9
commit
0135462bc7
16 files changed
+942
-2
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { z } from "zod"
|
||||
|
||||
// Anchored exactly to @appisoftsas.com — no subdomains/suffixes
|
||||
// (e.g. user@appisoftsas.com.evil.com must be rejected).
|
||||
const APPISOFT_EMAIL_REGEX = /^[^@\s]+@appisoftsas\.com$/i
|
||||
|
||||
export const registerSchema = z
|
||||
.object({
|
||||
email: z
|
||||
.string()
|
||||
.min(1, "El correo es obligatorio")
|
||||
.regex(APPISOFT_EMAIL_REGEX, "Debe usar un correo @appisoftsas.com"),
|
||||
displayName: z
|
||||
.string()
|
||||
.min(2, "El nombre debe tener al menos 2 caracteres")
|
||||
.max(100, "El nombre es demasiado largo"),
|
||||
password: z.string().min(8, "La contraseña debe tener al menos 8 caracteres"),
|
||||
confirmPassword: z.string().min(1, "Confirma tu contraseña"),
|
||||
})
|
||||
.refine((data) => data.password === data.confirmPassword, {
|
||||
message: "Las contraseñas no coinciden",
|
||||
path: ["confirmPassword"],
|
||||
})
|
||||
|
||||
export type RegisterInput = z.infer<typeof registerSchema>
|
||||
|
||||
export const loginSchema = z.object({
|
||||
email: z.string().min(1, "El correo es obligatorio"),
|
||||
password: z.string().min(1, "La contraseña es obligatoria"),
|
||||
})
|
||||
|
||||
export type LoginInput = z.infer<typeof loginSchema>
|
||||
Reference in new issue
Block a user