Registrierung und Login gefixt
This commit is contained in:
@@ -24,12 +24,12 @@ export class User {
|
||||
return user;
|
||||
}
|
||||
|
||||
public static async fromUsername(username: string): Promise<UserType | null> {
|
||||
if (!username || typeof username !== "string") {
|
||||
public static async fromEmail(email: string): Promise<UserType | null> {
|
||||
if (!email || typeof email !== "string") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const user = await db<UserType>("users").select("*").where("username", username).first();
|
||||
const user = await db<UserType>("users").select("*").where("email", email).first();
|
||||
|
||||
if (!user) {
|
||||
return null;
|
||||
@@ -66,7 +66,6 @@ export class User {
|
||||
const hashedPassword = hashPassword(user.password);
|
||||
|
||||
const result = await db<UserType>("users").insert({
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
password: hashedPassword,
|
||||
uid: uid
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const UserTypeValidator = z.object({
|
||||
username: z.string().min(4).max(64),
|
||||
id: z.number(),
|
||||
uid: z.string().length(36),
|
||||
email: z.string().max(255),
|
||||
@@ -9,7 +8,6 @@ export const UserTypeValidator = z.object({
|
||||
})
|
||||
|
||||
export const UserRegisterValidator = z.object({
|
||||
username: z.string().min(4).max(64),
|
||||
email: z.string().max(255),
|
||||
password: z.string().min(6),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user