various code cleanup and commenting
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user