groundwork for helpdesk stuff

This commit is contained in:
Nathan
2025-05-16 00:23:09 -07:00
parent 3461e9f618
commit 1c3427e63f
7 changed files with 214 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ import { randomStringBase62, getHumanReadableUserAgent } from "../liberals/misc.
app.get("/api/auth/whoami", (rreq,rres) => {
if (!rreq.cookies["APIToken"] && !rreq.get("Authorization")) {
rres.status(400).send({ "loggedIn": false, "username": "", "scopes": "" })
rres.send({ "loggedIn": false, "username": "", "scopes": "" })
} else {
db`select s.scopes, u.username from sessions s join users u on s.owner = u.id where s.token = ${rreq.cookies["APIToken"] ?? rreq.get("Authorization")}`.then(dbRes => {
if (dbRes.length > 0 && dbRes.length < 2) {

11
routes/helpdesk.js Normal file
View File

@@ -0,0 +1,11 @@
import { app } from "../index.js"
app.get("/helpdesk", (rreq, rres) => {
rres.sendFile(process.cwd()+"/website/helpdesk/templates/landing.html")
})
app.get("/helpdesk/articles/*", (rreq, rres) => {
rres.sendFile(process.cwd()+"/website/helpdesk/kbas/"+rreq.url.replace("/helpdesk/articles/",""))
})
export { app }