chore: use auth macro instead of checking it on every path

This commit is contained in:
C4illin 2025-10-02 17:29:58 +02:00
parent 13d9ce09a4
commit c9b65c7652
9 changed files with 69 additions and 113 deletions

View file

@ -7,16 +7,7 @@ import { userService } from "./user";
export const deleteFile = new Elysia().use(userService).post(
"/delete",
async ({ body, redirect, jwt, cookie: { auth, jobId } }) => {
if (!auth?.value) {
return redirect(`${WEBROOT}/login`, 302);
}
const user = await jwt.verify(auth.value);
if (!user) {
return redirect(`${WEBROOT}/login`, 302);
}
async ({ body, redirect, cookie: { jobId }, user }) => {
if (!jobId?.value) {
return redirect(`${WEBROOT}/`, 302);
}
@ -37,5 +28,5 @@ export const deleteFile = new Elysia().use(userService).post(
message: "File deleted successfully.",
};
},
{ body: t.Object({ filename: t.String() }) },
{ body: t.Object({ filename: t.String() }), auth: true },
);