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
|
|
@ -1,7 +1,7 @@
|
|||
import { randomInt } from "node:crypto";
|
||||
import { Html } from "@elysiajs/html";
|
||||
import { JWTPayloadSpec } from "@elysiajs/jwt";
|
||||
import { Elysia } from "elysia";
|
||||
import { Elysia, t } from "elysia";
|
||||
import { BaseHtml } from "../components/base";
|
||||
import { Header } from "../components/header";
|
||||
import { getAllTargets } from "../converters/main";
|
||||
|
|
@ -65,7 +65,7 @@ export const root = new Elysia()
|
|||
user.id &&
|
||||
(Number.parseInt(user.id) < 2 ** 24 || !ALLOW_UNAUTHENTICATED)
|
||||
) {
|
||||
// make sure user exists in db
|
||||
// Make sure user exists in db
|
||||
const existingUser = db.query("SELECT * FROM users WHERE id = ?").as(User).get(user.id);
|
||||
|
||||
if (!existingUser) {
|
||||
|
|
@ -240,4 +240,9 @@ export const root = new Elysia()
|
|||
</>
|
||||
</BaseHtml>
|
||||
);
|
||||
}, {
|
||||
cookie: t.Cookie({
|
||||
auth: t.Optional(t.String()),
|
||||
jobId: t.Optional(t.String()),
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue