admin schmadmin

This commit is contained in:
Flummi
2024-06-24 07:53:00 +02:00
parent 486580b21c
commit 2ff1842d09
11 changed files with 40 additions and 172 deletions

View File

@@ -134,15 +134,6 @@ export default new class {
const derivedKey = await scrypt(str, salt, 64);
return crypto.timingSafeEqual(keyBuffer, derivedKey);
};
async auth(req, res, next) {
if(!req.session) {
return res.reply({
code: 401,
body: "401 - Unauthorized"
});
}
return next();
};
async getTags(itemid) {
const tags = await db`
select "tags".id, "tags".tag, "tags".normalized, "user".user
@@ -217,6 +208,27 @@ export default new class {
TABLE_NAME='user_options' and
COLUMN_NAME = 'avatar'
`)[0].avatar;
}
};
// meddlware
async auth(req, res, next) {
if(!req.session || !req.session.admin) {
return res.reply({
code: 401,
body: "401 - Unauthorized"
});
}
return next();
};
async loggedin(req, res, next) {
if(!req.session) {
return res.reply({
code: 401,
body: "401 - Unauthorized"
});
}
return next();
};
};