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.
31 lines
1.1 KiB
31 lines
1.1 KiB
'use strict';
|
|
|
|
const { Boards } = require(__dirname+'/../../db/')
|
|
, dynamicResponse = require(__dirname+'/../../lib/misc/dynamic.js')
|
|
, Permission = require(__dirname+'/../../lib/permission/permission.js');
|
|
|
|
module.exports = async (req, res) => {
|
|
|
|
let updatingPermissions = new Permission(res.locals.board.staff[req.body.username].permissions);
|
|
|
|
updatingPermissions = new Permission(res.locals.board.staff[req.body.username].permissions);
|
|
updatingPermissions.handleBody(req.body, res.locals.permissions, true);
|
|
// updatingPermissions.applyInheritance();
|
|
|
|
const updated = await Boards.setStaffPermissions(req.params.board, req.body.username, updatingPermissions).then(r => r.matchedCount);
|
|
|
|
if (updated === 0) {
|
|
return dynamicResponse(req, res, 400, 'message', {
|
|
'title': 'Bad request',
|
|
'errors': 'Staff does not exist',
|
|
'redirect': req.headers.referer || `/${req.params.board}/manage/staff.html`,
|
|
});
|
|
}
|
|
|
|
return dynamicResponse(req, res, 200, 'message', {
|
|
'title': 'Success',
|
|
'message': 'Edited staff',
|
|
'redirect': `/${req.params.board}/manage/editstaff/${req.body.username}.html`,
|
|
});
|
|
|
|
};
|
|
|