various code cleanup and commenting

This commit is contained in:
2026-05-26 22:35:56 +00:00
parent 46295fabde
commit af2194a8b3
14 changed files with 229 additions and 123 deletions
+9 -5
View File
@@ -1,8 +1,6 @@
import { Router } from "express";
export const router = Router({ mergeParams: true });
const checkAuth = global.utils.checkAuth;
/**
* GET - get specific user
* request:
@@ -16,15 +14,21 @@ router.get("/:username", async (req, res) => {
username: req.params.username
};
// check auth
const auth = await checkAuth(req.cookies, res);
const auth = await global.utils.checkAuth(req.cookies, res);
if (!auth) {
return;
}
// attempt to parse user from username
const userObj = global.utils.getUserObjFromUsername(params.username);
if (userObj == null) {
res.status(400).send({ auth:true, error:`username ${params.username} does not match format uid@realm.` });
}
// get user
const u = await global.access.getUser(userObj, req.cookies);
if (u.ok !== true) {
res.status(u.status).send(u);
res.status(u.status).send({ auth: true, error: u });
return;
}
const user = u.user;