summaryrefslogtreecommitdiff
path: root/app/auth.js
diff options
context:
space:
mode:
authorAlexis Hovorka <[email protected]>2024-07-27 19:43:38 -0600
committerAlexis Hovorka <[email protected]>2024-07-27 19:43:38 -0600
commit4702402484a773c0eccf7415d0318e367fb996e1 (patch)
tree54f4857f5664b7f40815c580493bf08adc4dbe88 /app/auth.js
parentcaa495340aef5b765bed193da51cd4bf48a4d570 (diff)
[refactor] Try out some client-side UI librariesHEADmain
Diffstat (limited to 'app/auth.js')
-rw-r--r--app/auth.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/auth.js b/app/auth.js
index 8a55857..4d5c1cb 100644
--- a/app/auth.js
+++ b/app/auth.js
@@ -165,7 +165,7 @@ const checkReferer = req => {
if (req.headers["referer"] && !req.headers["referer"].includes(DOMAIN))
console.log(Date.now()+" [WARN] Unexpected HTTP Referer: "+req.headers["referer"]); };
-async function login(req, res, match, data) {
+async function signIn(req, res, match, data) {
const currentToken = parseCookies(req)?.token;
if (currentToken || !data.username || !data.password) return err400(res);
const error = {success:false, msg:"Bad username or password"};
@@ -206,7 +206,7 @@ async function login(req, res, match, data) {
} else return err500(res);
}
-function logout(req, res) {
+function signOut(req, res) {
const token = parseCookies(req)?.token;
const tokenData = getToken(token);
if (tokenData) {
@@ -419,8 +419,8 @@ export function authed(fn) { return rateLimit((req, res, ...rest) => {
}); }
export const attach = (app) => { // TODO make endpoints RESTier?
- app.jpost("/login", rateLimit(login)); // {username, password[, keepSession]} -> {success[, msg][, mustChangePassword]}
- app.post("/logout", rateLimit(logout));
+ app.jpost("/sign-in", rateLimit(signIn)); // {username, password[, keepSession]} -> {success[, msg][, mustChangePassword]}
+ app.post("/sign-out", rateLimit(signOut));
app.jpost("/change-password", rateLimit(changePassword)); // {password, newPassword[, username[, keepSession]]} -> {success[, msg]}
app.jpost("/change-username", authed(changeUsernameReq)); // {newUsername, password} -> {success[, msg]}
app.get("/session-list", authed(sessionList)); // -> {active:[{id:<sessionID>, ...}, ...], recent:[...]}