Finished up with global user bans.
This commit is contained in:
parent
26df91262f
commit
8fc699924e
13 changed files with 180 additions and 37 deletions
|
|
@ -19,6 +19,7 @@ const {validationResult, matchedData} = require('express-validator');
|
|||
|
||||
//local imports
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const userBanModel = require('../../../schemas/userBanSchema.js');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
|
|
@ -27,6 +28,17 @@ module.exports.post = async function(req, res){
|
|||
|
||||
if(validResult.isEmpty()){
|
||||
const user = matchedData(req);
|
||||
|
||||
//Would prefer to stick this in userModel.statics.register() but we end up with circular dependencies >:(
|
||||
const nukedBans = await userBanModel.checkProcessedBans(user.user);
|
||||
|
||||
//if we found any related nuked bans
|
||||
if(nukedBans != null){
|
||||
//Shit our pants!
|
||||
res.status(401);
|
||||
return res.send({errors:[{msg:"Cannot re-create banned account!",type:"unauthorized"}]});
|
||||
}
|
||||
|
||||
await userModel.register(user)
|
||||
return res.sendStatus(200);
|
||||
}else{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue