diff --git a/website/helpdesk/kbas/Enstrayed_Cloud-App_Passwords.md b/archive/Enstrayed_Cloud-App_Passwords.md similarity index 100% rename from website/helpdesk/kbas/Enstrayed_Cloud-App_Passwords.md rename to archive/Enstrayed_Cloud-App_Passwords.md diff --git a/website/helpdesk/kbas/example.html b/archive/example.html similarity index 100% rename from website/helpdesk/kbas/example.html rename to archive/example.html diff --git a/routes/auth.js b/routes/auth.js index 98ae8c1..59a79db 100644 --- a/routes/auth.js +++ b/routes/auth.js @@ -6,8 +6,8 @@ import { randomStringBase62, getHumanReadableUserAgent } from "../liberals/misc. app.get("/api/auth/whoami", (rreq,rres) => { if (!rreq.cookies["APIToken"] && !rreq.get("Authorization")) { 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 => { + } else { // select + db`select scopes,username from sessions where token = ${rreq.cookies["APIToken"] ?? rreq.get("Authorization")}`.then(dbRes => { if (dbRes.length > 0 && dbRes.length < 2) { rres.send({ "loggedIn": true, "username": dbRes[0]?.username, "scopes": dbRes[0]?.scopes.split(",") }) } else { @@ -75,7 +75,7 @@ app.get("/api/auth/callback", (rreq,rres) => { let newExpiration = Date.now() + 86400 let newComment = `Login token for ${getHumanReadableUserAgent(rreq.get("User-Agent"))} on ${rreq.get("cf-connecting-ip") ?? rreq.ip}` - db`insert into sessions (token,owner,scopes,expires,comment) values (${newToken},(select id from users where oidc_username = ${fetchRes2.username}),${fetchRes2.enstrayedapi_scopes},${newExpiration},${newComment});`.then(dbRes1 => { + db`insert into sessions (token,username,scopes,expires,comment) values (${newToken},${fetchRes2.username},${fetchRes2.enstrayedapi_scopes},${newExpiration},${newComment});`.then(dbRes1 => { if (rreq.query.state.split("_")[0] === "redirect") { let newDestination = atob(rreq.query.state.split("_")[1].replace("-","/")) rres.setHeader("Set-Cookie", `APIToken=${newToken}; Domain=${rreq.hostname}; Expires=${new Date(newExpiration).toUTCString()}; Path=/`).redirect(newDestination) diff --git a/routes/dynamic.js b/routes/dynamic.js index 905777b..c3486fb 100644 --- a/routes/dynamic.js +++ b/routes/dynamic.js @@ -8,4 +8,12 @@ app.get("/dynamic/icon/*", (rreq, rres) => { } catch { rres.sendStatus(404) } +}) + +app.get("/dynamic/background/*", (rreq,rres) => { + if (rreq.headers["accept"].includes("image/jxl")) { + rres.setHeader("Content-Type", "image/jxl").sendFile( `${process.cwd()}/website/dynamic/backgrounds/${rreq.path.split("/")[3]}.jxl`) + } else { + rres.setHeader("Content-Type", "image/jpeg").sendFile( `${process.cwd()}/website/dynamic/backgrounds/${rreq.path.split("/")[3]}.jpg`) + } }) \ No newline at end of file diff --git a/routes/helpdesk.js b/routes/helpdesk.js index 270ea95..2d893de 100644 --- a/routes/helpdesk.js +++ b/routes/helpdesk.js @@ -26,7 +26,14 @@ app.get("/helpdesk/ticket/new", (rreq,rres) => { }) app.get("/api/helpdesk/forms/*", (rreq, rres) => { - rres.sendFile(process.cwd()+"/website/helpdesk/forms/"+rreq.url.replace("/api/helpdesk/forms/","")) + fs.readFile(process.cwd()+"/website/helpdesk/forms/"+rreq.url.replace("/api/helpdesk/forms/","")+".json","utf-8", (error, data) => { + if (error) { + rres.status(400).send("Unable to retrieve requested form") + } else { + rres.type('json').send(data) + } + }) + }) app.get("/helpdesk/static/*", (rreq,rres) => { diff --git a/website/dynamic/backgrounds/main.jpg b/website/dynamic/backgrounds/main.jpg new file mode 100644 index 0000000..b38ce29 Binary files /dev/null and b/website/dynamic/backgrounds/main.jpg differ diff --git a/website/dynamic/backgrounds/main.jxl b/website/dynamic/backgrounds/main.jxl new file mode 100644 index 0000000..bfa31eb Binary files /dev/null and b/website/dynamic/backgrounds/main.jxl differ diff --git a/website/helpdesk/forms/enstrayedcloud_quotachange.json b/website/helpdesk/forms/enstrayedcloud_quotachange.json deleted file mode 100644 index 7e03fc1..0000000 --- a/website/helpdesk/forms/enstrayedcloud_quotachange.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "anonymousSubmission": false, - "form": { - "description": { - "type": "span", - "content": "Important: " - }, - "newquota": { - "type": "text", - "content": "New quota (in GB)", - "required": true - } - } -} \ No newline at end of file diff --git a/website/helpdesk/forms/general_inquiry.json b/website/helpdesk/forms/general_inquiry.json index ae5d662..3345395 100644 --- a/website/helpdesk/forms/general_inquiry.json +++ b/website/helpdesk/forms/general_inquiry.json @@ -4,10 +4,6 @@ "type": "text", "content": "What is your name?" }, - "email": { - "type": "text", - "content": "What is a good email address to reach you at?" - }, "message": { "type": "bigtext", "content": "Please enter your message below." diff --git a/website/helpdesk/forms/manifest.json b/website/helpdesk/forms/manifest.json index 9807937..cc55285 100644 --- a/website/helpdesk/forms/manifest.json +++ b/website/helpdesk/forms/manifest.json @@ -5,6 +5,5 @@ "general_techsupport": "General Technical Support", "ecls_deleteaccount": "ECLS: Delete Account", "ecls_passwordreset": "ECLS: Password Reset", - "ecls_personalinfochange": "ECLS: Personal Information Change", - "enstrayedcloud_quotachange": "Enstrayed Cloud: Quota Change" + "ecls_personalinfochange": "ECLS: Personal Information Change" } \ No newline at end of file diff --git a/website/helpdesk/static/helpdesk.css b/website/helpdesk/static/helpdesk.css index c0eaf45..43badab 100644 --- a/website/helpdesk/static/helpdesk.css +++ b/website/helpdesk/static/helpdesk.css @@ -57,23 +57,8 @@ body { margin: 0 0 0.5em 0; } -.articlecontent { - background-color: #fff; - padding: 2em; - margin: 2em 0 2em; - max-width: 100ch; -} - -.articlecontent > h1 { - margin: 0 0 0.5em; -} - -.articlecontent > ol > li { - margin: 0 0 0.2em; -} - -.articlecontent img { - max-width: 100%; +.helpdeskScopeOnly { + display: none; } .linkColumn { @@ -107,3 +92,30 @@ dialog::backdrop { background-color: rgba(0, 0, 0, 0.5); } +#formarea > div > input { + width: 50%; +} + +#formarea > div > textarea { + width: 100%; +} + +/* Article Specific */ +.articlecontent { + background-color: #fff; + padding: 2em; + margin: 2em 0 2em; + max-width: 100ch; +} + +.articlecontent > h1 { + margin: 0 0 0.5em; +} + +.articlecontent > ol > li { + margin: 0 0 0.2em; +} + +.articlecontent img { + max-width: 100%; +} \ No newline at end of file diff --git a/website/helpdesk/static/login.js b/website/helpdesk/static/login.js index 71d43a2..ddea057 100644 --- a/website/helpdesk/static/login.js +++ b/website/helpdesk/static/login.js @@ -12,6 +12,14 @@ document.addEventListener("DOMContentLoaded", function () { if (jsonRes.loggedIn) { globalLoggedIn = true document.getElementById("loginButton").innerText = `Logout ${jsonRes.username}` + + if (jsonRes.scopes.includes("helpdesk")) { + let targetElements = document.getElementsByClassName("helpdeskScopeOnly") + // cant do a for loop since targetElements dynamically updates, this is easier but stupid + while (targetElements.length > 0) { + targetElements[0].classList.toggle("helpdeskScopeOnly") + } + } } else { globalLoggedIn = false document.getElementById("loginButton").innerText = `Login` @@ -24,8 +32,7 @@ function loginFunction() { if (globalLoggedIn === true) { fetch(`/api/auth/logout`).then(fetchRes => { if (fetchRes.status === 200) { - globalLoggedIn = false - document.getElementById("loginButton").innerText = `Login` + location.reload() } else { fetchRes.text().then(textRes => { useGlobalDialog("Error", `An error occurred during logout: ${textRes}`) @@ -41,6 +48,13 @@ function loginFunction() { if (jsonRes.loggedIn) { globalLoggedIn = true document.getElementById("loginButton").innerText = `Logout ${jsonRes.username}` + + if (jsonRes.scopes.includes("helpdesk")) { + let targetElements = document.getElementsByClassName("helpdeskScopeOnly") + while (targetElements.length > 0) { + targetElements[0].classList.toggle("helpdeskScopeOnly") + } + } } else { useGlobalDialog("Error", `You are not logged in. Please try logging in again.`) } diff --git a/website/helpdesk/templates/article.html b/website/helpdesk/templates/article.html index 19f594c..4f7cdac 100644 --- a/website/helpdesk/templates/article.html +++ b/website/helpdesk/templates/article.html @@ -10,8 +10,8 @@
-

Enstrayed Helpdesk

- Open Ticket + Enstrayed Helpdesk + New Request Knowledgebase
diff --git a/website/helpdesk/templates/landing.html b/website/helpdesk/templates/landing.html index ce918bf..6df3285 100644 --- a/website/helpdesk/templates/landing.html +++ b/website/helpdesk/templates/landing.html @@ -11,8 +11,9 @@
Enstrayed Helpdesk - Open Ticket + New Request Knowledgebase + Ticket List
diff --git a/website/helpdesk/templates/newticket.html b/website/helpdesk/templates/newticket.html index 023fb72..72a8047 100644 --- a/website/helpdesk/templates/newticket.html +++ b/website/helpdesk/templates/newticket.html @@ -9,11 +9,9 @@ @@ -30,23 +55,31 @@ +
-

New Ticket

- - +

New Request

+
+ + +

+ +
+ +
+

Warning

This is a warning

diff --git a/website/static/newindex.css b/website/static/newindex.css index eaf5234..e077493 100644 --- a/website/static/newindex.css +++ b/website/static/newindex.css @@ -1,9 +1,8 @@ html { background-color: #0f0f0f; - background-image: url('/static/bridge2.jpg'); - /*! background-size: 100%; */ + background-image: url('/dynamic/background/main'); + background-size: cover; background-position-y: 50%; - background-position-x: center; height: 100%; } @@ -64,7 +63,6 @@ body { flex-direction: column; justify-content: center; gap: 0.2em; - max-width: 14em; } #nowplaying .nowPlayingLine2 {