mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 15:08:46 +00:00
Revert "데모용 임시 회원가입 구현"
This reverts commit eb913366646f43fda669f0550788e0888c44b95a.
This commit is contained in:
@@ -7,15 +7,6 @@ interface User {
|
||||
password: string;
|
||||
}
|
||||
|
||||
export const createUser = async (email: string, nickname: string, password: string) => {
|
||||
const { id } = await db
|
||||
.insertInto("user")
|
||||
.values({ email, nickname, password })
|
||||
.returning("id")
|
||||
.executeTakeFirstOrThrow();
|
||||
return { id, email, nickname, password } satisfies User;
|
||||
};
|
||||
|
||||
export const getUser = async (userId: number) => {
|
||||
const user = await db
|
||||
.selectFrom("user")
|
||||
|
||||
@@ -3,7 +3,7 @@ import { authenticate, AuthenticationError } from "$lib/server/modules/auth";
|
||||
|
||||
export const authenticateMiddleware: Handle = async ({ event, resolve }) => {
|
||||
const { pathname, search } = event.url;
|
||||
if (pathname === "/api/auth/login" || pathname === "/api/auth/register") {
|
||||
if (pathname === "/api/auth/login") {
|
||||
return await resolve(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,6 @@ export const loginRequest = z.object({
|
||||
});
|
||||
export type LoginRequest = z.infer<typeof loginRequest>;
|
||||
|
||||
export const registerRequest = z.object({
|
||||
email: z.string().email(),
|
||||
nickname: z.string().trim().min(2).max(8),
|
||||
password: z.string().trim().nonempty(),
|
||||
});
|
||||
export type RegisterRequest = z.infer<typeof registerRequest>;
|
||||
|
||||
export const sessionUpgradeRequest = z.object({
|
||||
encPubKey: z.string().base64().nonempty(),
|
||||
sigPubKey: z.string().base64().nonempty(),
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
registerSessionUpgradeChallenge,
|
||||
consumeSessionUpgradeChallenge,
|
||||
} from "$lib/server/db/session";
|
||||
import { createUser, getUser, getUserByEmail, setUserPassword } from "$lib/server/db/user";
|
||||
import { getUser, getUserByEmail, setUserPassword } from "$lib/server/db/user";
|
||||
import env from "$lib/server/loadenv";
|
||||
import { startSession } from "$lib/server/modules/auth";
|
||||
import { verifySignature, generateChallenge } from "$lib/server/modules/crypto";
|
||||
@@ -65,27 +65,6 @@ export const logout = async (sessionId: string) => {
|
||||
await deleteSession(sessionId);
|
||||
};
|
||||
|
||||
export const register = async (
|
||||
email: string,
|
||||
nickname: string,
|
||||
password: string,
|
||||
ip: string,
|
||||
userAgent: string,
|
||||
) => {
|
||||
if (password.length < 8) {
|
||||
error(400, "Too short password");
|
||||
}
|
||||
|
||||
const existingUser = await getUserByEmail(email);
|
||||
if (existingUser) {
|
||||
error(409, "Email already registered");
|
||||
}
|
||||
|
||||
const hashedPassword = await hashPassword(password);
|
||||
const { id } = await createUser(email, nickname, hashedPassword);
|
||||
return { sessionIdSigned: await startSession(id, ip, userAgent) };
|
||||
};
|
||||
|
||||
export const createSessionUpgradeChallenge = async (
|
||||
sessionId: string,
|
||||
userId: number,
|
||||
|
||||
Reference in New Issue
Block a user