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
980 B
38 lines
980 B
5 years ago
|
'use strict';
|
||
|
|
||
|
const transferBoard = require(__dirname+'/../../models/forms/transferboard.js')
|
||
|
, alphaNumericRegex = require(__dirname+'/../../helpers/checks/alphanumregex.js');
|
||
|
|
||
|
module.exports = async (req, res, next) => {
|
||
|
|
||
|
const errors = [];
|
||
|
|
||
|
if (!req.body.username || req.body.username.length === 0) {
|
||
|
errors.push('Missing transfer username');
|
||
|
}
|
||
|
if (req.body.username && req.body.username.length > 50) {
|
||
|
errors.push('Transfer username must be at less than 50 characters');
|
||
|
}
|
||
|
if (req.body.username === res.locals.board.owner) {
|
||
|
errors.push('You are already board owner...');
|
||
|
}
|
||
|
if (alphaNumericRegex.test(req.body.username) !== true) {
|
||
|
errors.push('URI must contain a-z 0-9 only');
|
||
|
}
|
||
|
|
||
|
if (errors.length > 0) {
|
||
|
return res.status(400).render('message', {
|
||
|
'title': 'Bad request',
|
||
|
'errors': errors,
|
||
|
'redirect': `/${req.params.board}/manage.html`
|
||
|
})
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
await transferBoard(req, res, next);
|
||
|
} catch (err) {
|
||
|
return next(err);
|
||
|
}
|
||
|
|
||
|
}
|