Alexandria commit
- Commit to using Alexandria DB - Fixed a bug when a user didn't exist but loading was attempted
This commit is contained in:
parent
3ee7a3a515
commit
1f9970929f
12 changed files with 61 additions and 664 deletions
|
@ -17,9 +17,9 @@ const cairoMiddleware = (req, res, next) => {
|
|||
headers: { authorization: `Bearer ${req.token}` },
|
||||
})
|
||||
.then((authRes) => {
|
||||
if (authRes.status !== 200) return res.status(authres.status);
|
||||
if (authRes.data != null && authRes.data.uuid != null) {
|
||||
asUser.load(authRes.data.uuid).then((user) => {
|
||||
if (authRes.status !== 200) return res.sendStatus(authres.status);
|
||||
if (authRes.data != null && authRes.data.id != null) {
|
||||
asUser.load(authRes.data.id).then((user) => {
|
||||
req.user = user;
|
||||
next();
|
||||
});
|
||||
|
@ -30,14 +30,15 @@ const cairoMiddleware = (req, res, next) => {
|
|||
else res.sendStatus(500);
|
||||
});
|
||||
};
|
||||
router.use(cairoMiddleware);
|
||||
|
||||
const authMiddleware = (req, res, next) => {
|
||||
if (req.token == null) return res.sendStatus(401);
|
||||
next();
|
||||
};
|
||||
router.use(cairoMiddleware);
|
||||
|
||||
router.get("/files", authMiddleware, (req, res) =>
|
||||
asUser.getOwnedFiles(req.user._id).then((files) => {
|
||||
asUser.getOwnedFiles(req.user.owned).then((files) => {
|
||||
res.status(200).json(files);
|
||||
})
|
||||
);
|
||||
|
|
Reference in a new issue