chore: comanyName is now optional and added confirmPassword field

This commit is contained in:
Pablo Lara
2024-10-01 14:13:49 +02:00
parent e15690781f
commit 2e443db362
2 changed files with 15 additions and 12 deletions
+11 -11
View File
@@ -32,17 +32,17 @@ export const authConfig = {
newUser: "/sign-up",
},
callbacks: {
authorized({ auth, request: { nextUrl } }) {
const isLoggedIn = !!auth?.user;
const isOnDashboard = nextUrl.pathname.startsWith("/");
if (isOnDashboard) {
if (isLoggedIn) return true;
return false; // Redirect unauthenticated users to login page
} else if (isLoggedIn) {
return Response.redirect(new URL("/", nextUrl));
}
return true;
},
// authorized({ auth, request: { nextUrl } }) {
// const isLoggedIn = !!auth?.user;
// const isOnDashboard = nextUrl.pathname.startsWith("/");
// if (isOnDashboard) {
// if (isLoggedIn) return true;
// return false; // Redirect unauthenticated users to login page
// } else if (isLoggedIn) {
// return Response.redirect(new URL("/", nextUrl));
// }
// return true;
// },
jwt({ token, user }) {
if (user) {
+4 -1
View File
@@ -3,7 +3,8 @@ import { z } from "zod";
export const authFormSchema = (type: string) =>
z.object({
// Sign Up
companyName: type === "sign-in" ? z.string().optional() : z.string().min(3),
companyName:
type === "sign-in" ? z.string().optional() : z.string().min(3).optional(),
firstName:
type === "sign-in"
? z.string().optional()
@@ -13,6 +14,8 @@ export const authFormSchema = (type: string) =>
message: "The name must be at least 3 characters.",
})
.max(20),
confirmPassword:
type === "sign-in" ? z.string().optional() : z.string().min(6),
termsAndConditions:
type === "sign-in"
? z.enum(["true"]).optional()