Started global user bans (DB schema/admin panel)
This commit is contained in:
parent
5c30508e96
commit
f996018ea5
20 changed files with 339 additions and 15 deletions
|
|
@ -16,7 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
const userModel = require('../schemas/userSchema');
|
||||
const {userModel} = require('../schemas/userSchema');
|
||||
const permissionModel = require('../schemas/permissionSchema');
|
||||
const channelModel = require('../schemas/channel/channelSchema');
|
||||
const {exceptionHandler} = require("../utils/loggerUtils");
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
|
|
|
|||
59
src/controllers/api/admin/banController.js
Normal file
59
src/controllers/api/admin/banController.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const banModel = require('../../../schemas/userBanSchema');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils');
|
||||
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
//get bans
|
||||
const bans = await banModel.getBans();
|
||||
|
||||
//send bans
|
||||
res.status(200);
|
||||
return res.send(bans);
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
const validResult = validationResult(req);
|
||||
if(validResult.isEmpty()){
|
||||
const {user} = matchedData(req);
|
||||
const userDB = await userModel.findOne({user});
|
||||
|
||||
if(userDB == null){
|
||||
res.status(400);
|
||||
res.send({errors:[{type: "Bad Query", msg: "User not found.", date: new Date()}]});
|
||||
}
|
||||
|
||||
await banModel.banByUserDoc(userDB);
|
||||
|
||||
}else{
|
||||
res.status(400);
|
||||
return res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ const {validationResult, matchedData} = require('express-validator');
|
|||
//local imports
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils');
|
||||
const permissionModel = require('../../../schemas/permissionSchema');
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
|
||||
//api change rank functions
|
||||
module.exports.post = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
|
||||
//local imports
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
|
||||
//api list account functions
|
||||
module.exports.get = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const {validationResult, matchedData} = require('express-validator');
|
|||
//local imports
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils');
|
||||
const permissionModel = require('../../../schemas/permissionSchema');
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
|
||||
//api channel rank functions
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ const {validationResult, matchedData} = require('express-validator');
|
|||
|
||||
//local imports
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
const userModel = require('../../../schemas/userSchema.js');
|
||||
const {userModel} = require('../../../schemas/userSchema.js');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
|
||||
//api account functions
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//Local Imports
|
||||
const userModel = require('../schemas/userSchema');
|
||||
const {userModel} = require('../schemas/userSchema');
|
||||
const {exceptionHandler} = require('../utils/loggerUtils.js');
|
||||
|
||||
//Config
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue