hotfix
This commit is contained in:
@@ -9,11 +9,19 @@ import { human } from "./human";
|
||||
import dayjs from "dayjs";
|
||||
import db from "./db";
|
||||
import { liveTable, WsOut, WsIn } from "./table";
|
||||
import { Human } from "@prisma/client";
|
||||
|
||||
const api = new Elysia({ prefix: "/api" })
|
||||
.post("/whoami", async ({ cookie: { token } }) => {
|
||||
let human;
|
||||
if (token.value == null) {
|
||||
let human: Human | null;
|
||||
if (
|
||||
token.value == null ||
|
||||
(human = await db.human.findUnique({
|
||||
where: {
|
||||
token: token.value,
|
||||
},
|
||||
})) == null
|
||||
) {
|
||||
human = await db.human.create({
|
||||
data: {},
|
||||
});
|
||||
@@ -22,13 +30,8 @@ const api = new Elysia({ prefix: "/api" })
|
||||
expires: dayjs().add(1, "year").toDate(),
|
||||
httpOnly: true,
|
||||
});
|
||||
} else {
|
||||
human = await db.human.findUniqueOrThrow({
|
||||
where: {
|
||||
token: token.value,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return human.key;
|
||||
})
|
||||
.use(human)
|
||||
|
||||
Reference in New Issue
Block a user