|
|
@ -15,20 +15,12 @@ module.exports = { |
|
|
|
|
|
|
|
|
|
|
|
controller: async (req, res, next) => { |
|
|
|
controller: async (req, res, next) => { |
|
|
|
|
|
|
|
|
|
|
|
const errors = []; |
|
|
|
const errors = checkSchema([ |
|
|
|
|
|
|
|
{ result: existsBody(req.body.username), expected: true, error: 'Missing new owner username' }, |
|
|
|
if (!req.body.username || req.body.username.length === 0) { |
|
|
|
{ result: lengthBody(req.body.username, 1, 50), expected: true, error: 'New owner username must be 50 characters or less' }, |
|
|
|
errors.push('Missing transfer username'); |
|
|
|
{ result: (req.body.username === res.locals.board.owner), expected: false, error: 'New owner must be different from current owner' }, |
|
|
|
} |
|
|
|
{ result: alphaNumericRegex.test(req.body.username), expected: true, error: 'New owner username must contain a-z 0-9 only' }, |
|
|
|
if (req.body.username && req.body.username.length > 50) { |
|
|
|
]); |
|
|
|
errors.push('Transfer username must be 50 characters or less'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (req.body.username === res.locals.board.owner) { |
|
|
|
|
|
|
|
errors.push('New owner username must not be same as old owner'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (alphaNumericRegex.test(req.body.username) !== true) { |
|
|
|
|
|
|
|
errors.push('Username must contain a-z 0-9 only'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (errors.length > 0) { |
|
|
|
if (errors.length > 0) { |
|
|
|
return dynamicResponse(req, res, 400, 'message', { |
|
|
|
return dynamicResponse(req, res, 400, 'message', { |
|
|
|