Refactored a bunch of shit
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m57s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m57s
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
siteSettings,
|
||||
} from "../../../db/schema";
|
||||
import { hashPassword, createSession } from "../../../lib/auth";
|
||||
import { isValidEmail, MAX_LENGTHS } from "../../../lib/validation";
|
||||
import { eq, count, sql } from "drizzle-orm";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
@@ -37,6 +38,18 @@ export const POST: APIRoute = async ({ request, cookies, redirect }) => {
|
||||
return redirect("/signup?error=missing_fields");
|
||||
}
|
||||
|
||||
if (!isValidEmail(email)) {
|
||||
return redirect("/signup?error=invalid_email");
|
||||
}
|
||||
|
||||
if (name.length > MAX_LENGTHS.name) {
|
||||
return redirect("/signup?error=name_too_long");
|
||||
}
|
||||
|
||||
if (password.length > MAX_LENGTHS.password) {
|
||||
return redirect("/signup?error=password_too_long");
|
||||
}
|
||||
|
||||
if (password.length < 8) {
|
||||
return redirect("/signup?error=password_too_short");
|
||||
}
|
||||
@@ -47,7 +60,7 @@ export const POST: APIRoute = async ({ request, cookies, redirect }) => {
|
||||
.where(eq(users.email, email))
|
||||
.get();
|
||||
if (existingUser) {
|
||||
return redirect("/signup?error=user_exists");
|
||||
return redirect("/login?registered=true");
|
||||
}
|
||||
|
||||
const passwordHash = await hashPassword(password);
|
||||
|
||||
Reference in New Issue
Block a user