Token Upgrade시 챌린지를 거치도록 변경

This commit is contained in:
static
2024-12-31 03:01:29 +09:00
parent 4f20d2edbf
commit b84d6fd5ad
14 changed files with 208 additions and 69 deletions

View File

@@ -10,14 +10,12 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
.object({
email: z.string().email().nonempty(),
password: z.string().nonempty(),
pubKey: z.string().base64().nonempty().optional(),
})
.safeParse(await request.json());
if (!zodRes.success) error(400, "Invalid request body");
const { email, password } = zodRes.data;
const { email, password, pubKey } = zodRes.data;
const { accessToken, refreshToken } = await login(email.trim(), password.trim(), pubKey?.trim());
const { accessToken, refreshToken } = await login(email.trim(), password.trim());
cookies.set("accessToken", accessToken, {
path: "/",
maxAge: Math.floor(ms(env.jwt.accessExp) / 1000),
@@ -28,5 +26,6 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
maxAge: Math.floor(ms(env.jwt.refreshExp) / 1000),
sameSite: "strict",
});
return text("Logged in", { headers: { "Content-Type": "text/plain" } });
};