mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
872 B
24 lines
872 B
'use strict';
|
|
|
|
const { Boards, Accounts } = require(__dirname+'/../../db/')
|
|
, dynamicResponse = require(__dirname+'/../../lib/misc/dynamic.js');
|
|
|
|
module.exports = async (req, res) => {
|
|
|
|
//only a ROOT could do this, per the permission bypass in the controller
|
|
const deletingBoardOwner = req.body.checkedstaff.some(s => s === res.locals.board.owner);
|
|
|
|
await Promise.all([
|
|
Accounts.removeStaffBoard(req.body.checkedstaff, res.locals.board._id),
|
|
Boards.removeStaff(res.locals.board._id, req.body.checkedstaff),
|
|
deletingBoardOwner ? Accounts.removeOwnedBoard(res.locals.board.owner, res.locals.board._id) : void 0,
|
|
deletingBoardOwner ? Boards.setOwner(res.locals.board._id, null) : void 0,
|
|
]);
|
|
|
|
return dynamicResponse(req, res, 200, 'message', {
|
|
'title': 'Success',
|
|
'message': 'Deleted staff',
|
|
'redirect': `/${req.params.board}/manage/staff.html`,
|
|
});
|
|
|
|
};
|
|
|