chore: use auth macro instead of checking it on every path
This commit is contained in:
parent
13d9ce09a4
commit
c9b65c7652
9 changed files with 69 additions and 113 deletions
|
|
@ -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 },
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue