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

@ -8,16 +8,7 @@ import { userService } from "./user";
export const listConverters = new Elysia()
.use(userService)
.get("/converters", async ({ jwt, redirect, cookie: { auth } }) => {
if (!auth?.value) {
return redirect(`${WEBROOT}/login`, 302);
}
const user = await jwt.verify(auth.value);
if (!user) {
return redirect(`${WEBROOT}/login`, 302);
}
.get("/converters", async () => {
return (
<BaseHtml webroot={WEBROOT} title="ConvertX | Converters">
<>
@ -77,4 +68,6 @@ export const listConverters = new Elysia()
</>
</BaseHtml>
);
}, {
auth: true
});