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

@ -9,16 +9,11 @@ import { userService } from "./user";
export const history = new Elysia()
.use(userService)
.get("/history", async ({ jwt, redirect, cookie: { auth } }) => {
.get("/history", async ({ jwt, redirect, user }) => {
if (HIDE_HISTORY) {
return redirect(`${WEBROOT}/`, 302);
}
if (!auth?.value) {
return redirect(`${WEBROOT}/login`, 302);
}
const user = await jwt.verify(auth.value);
if (!user) {
return redirect(`${WEBROOT}/login`, 302);
}
@ -32,7 +27,7 @@ export const history = new Elysia()
job.files_detailed = files;
}
// filter out jobs with no files
// Filter out jobs with no files
userJobs = userJobs.filter((job) => job.num_files > 0);
return (
@ -213,4 +208,6 @@ export const history = new Elysia()
</>
</BaseHtml>
);
}, {
auth: true
});