Implemented permabans

This commit is contained in:
2021-03-28 08:32:28 +11:00
parent e597974581
commit 547d5dba1c
7 changed files with 106 additions and 1 deletions
+20
View File
@@ -1,6 +1,8 @@
const express = require('express');
const router = express.Router();
const { accounts } = require('../database/models');
//middleware
const tokenAuth = require('../utilities/token-auth');
@@ -15,6 +17,24 @@ router.post('/token', require('./token'));
//middleware
router.use(tokenAuth);
router.use(async (req, res, next) => {
const record = await accounts.findOne({
where: {
username: req.user.username
}
});
if (!record) {
return res.status(500).send('Account not found in banning middleware');
}
if (record.banned) {
return res.status(403).send('This account has been banned');
}
next();
});
//basic account management (needs a token)
router.delete('/logout', require('./logout'));
router.get('/account', require('./account-query'));