added footer links, added email alias check
This commit is contained in:
@@ -6,22 +6,29 @@ import { register } from "../action";
|
||||
import { signIn } from "next-auth/react";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import clsx, { ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { Button } from "../../../_components/ui/Button";
|
||||
import { useErrorBoundary } from "react-error-boundary";
|
||||
import { sendVerificationLink } from "(app)/admin/user/action";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
export const Register = () => {
|
||||
const { showBoundary } = useErrorBoundary();
|
||||
const schema = z
|
||||
.object({
|
||||
email: z.string().email({
|
||||
message: "Please enter a valid email",
|
||||
}),
|
||||
email: z
|
||||
.string()
|
||||
.email({ message: "Please enter a valid email" })
|
||||
.refine(
|
||||
(value) => {
|
||||
// Regex to check for email aliases like + or %
|
||||
const emailAliasRegex = /[+%]/;
|
||||
return !emailAliasRegex.test(value);
|
||||
},
|
||||
{
|
||||
message: "Email-Aliase (wie + oder %) sind nicht erlaubt",
|
||||
},
|
||||
),
|
||||
firstname: z.string().min(2).max(30),
|
||||
lastname: z.string().min(2).max(30),
|
||||
password: z.string(),
|
||||
password: z.string().min(12),
|
||||
passwordConfirm: z.string(),
|
||||
})
|
||||
.superRefine(({ password, passwordConfirm }, ctx) => {
|
||||
@@ -29,7 +36,7 @@ export const Register = () => {
|
||||
ctx.addIssue({
|
||||
code: "custom",
|
||||
message: "Die Passwörter stimmen nicht überein",
|
||||
path: ["confirmPassword"],
|
||||
path: ["passwordConfirm"],
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -46,7 +53,7 @@ export const Register = () => {
|
||||
passwordConfirm: "",
|
||||
},
|
||||
});
|
||||
|
||||
console.log("Register form", form.formState.errors);
|
||||
return (
|
||||
<form
|
||||
className="card-body"
|
||||
@@ -66,9 +73,14 @@ export const Register = () => {
|
||||
email: user.email,
|
||||
password: values.password,
|
||||
});
|
||||
setIsLoading(false);
|
||||
} catch (error) {
|
||||
showBoundary(error);
|
||||
toast.error(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Es ist ein Fehler aufgetreten. Bitte versuche es später erneut.",
|
||||
);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
})}
|
||||
>
|
||||
@@ -133,12 +145,7 @@ export const Register = () => {
|
||||
<path d="M2.5 3A1.5 1.5 0 0 0 1 4.5v.793c.026.009.051.02.076.032L7.674 8.51c.206.1.446.1.652 0l6.598-3.185A.755.755 0 0 1 15 5.293V4.5A1.5 1.5 0 0 0 13.5 3h-11Z" />
|
||||
<path d="M15 6.954 8.978 9.86a2.25 2.25 0 0 1-1.956 0L1 6.954V11.5A1.5 1.5 0 0 0 2.5 13h11a1.5 1.5 0 0 0 1.5-1.5V6.954Z" />
|
||||
</svg>
|
||||
<input
|
||||
type="text"
|
||||
className="grow"
|
||||
{...form.register("email")}
|
||||
placeholder="Email"
|
||||
/>
|
||||
<input type="text" className="grow" {...form.register("email")} placeholder="Email" />
|
||||
</label>
|
||||
|
||||
<p className="text-error">
|
||||
@@ -199,11 +206,7 @@ export const Register = () => {
|
||||
: ""}
|
||||
</p>
|
||||
<div className="card-actions mt-6">
|
||||
<Button
|
||||
disabled={isLoading}
|
||||
isLoading={isLoading}
|
||||
className="btn btn-primary btn-block"
|
||||
>
|
||||
<Button disabled={isLoading} isLoading={isLoading} className="btn btn-primary btn-block">
|
||||
Registrieren
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user