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.
38 lines
991 B
38 lines
991 B
5 years ago
|
'use strict';
|
||
|
|
||
3 years ago
|
const deleteAccounts = require(__dirname+'/../../models/forms/deleteaccounts.js')
|
||
3 years ago
|
, dynamicResponse = require(__dirname+'/../../helpers/dynamic.js')
|
||
|
, paramConverter = require(__dirname+'/../../helpers/paramconverter.js')
|
||
|
, { checkSchema, lengthBody, numberBody, minmaxBody, numberBodyVariable,
|
||
|
inArrayBody, arrayInBody, existsBody } = require(__dirname+'/../../helpers/schema.js');
|
||
5 years ago
|
|
||
3 years ago
|
module.exports = {
|
||
5 years ago
|
|
||
3 years ago
|
paramConverter: paramConverter({
|
||
|
allowedArrays: ['checkedaccounts'],
|
||
|
}),
|
||
5 years ago
|
|
||
3 years ago
|
controller: async (req, res, next) => {
|
||
5 years ago
|
|
||
3 years ago
|
const errors = await checkSchema([
|
||
|
{ result: lengthBody(req.body.checkedaccounts, 1), expected: false, error: 'Must select at least one account' },
|
||
|
]);
|
||
3 years ago
|
|
||
|
if (errors.length > 0) {
|
||
|
return dynamicResponse(req, res, 400, 'message', {
|
||
|
'title': 'Bad request',
|
||
|
'errors': errors,
|
||
|
'redirect': '/globalmanage/accounts.html'
|
||
|
})
|
||
|
}
|
||
|
|
||
|
try {
|
||
3 years ago
|
await deleteAccounts(req, res, next);
|
||
3 years ago
|
} catch (err) {
|
||
|
return next(err);
|
||
|
}
|
||
5 years ago
|
|
||
|
}
|
||
|
|
||
|
}
|