'use strict'; const loginAccount = require(__dirname+'/../../models/forms/login.js') , dynamicResponse = require(__dirname+'/../../helpers/dynamic.js'); module.exports = async (req, res, next) => { const errors = []; //check exist if (!req.body.username || req.body.username.length <= 0) { errors.push('Missing username'); } if (!req.body.password || req.body.password.length <= 0) { errors.push('Missing password'); } //check too long if (req.body.username && req.body.username.length > 50) { errors.push('Username must be 50 characters or less'); } if (req.body.password && req.body.password.length > 100) { errors.push('Password must be 100 characters or less'); } if (errors.length > 0) { return dynamicResponse(req, res, 400, 'message', { 'title': 'Bad request', 'errors': errors, 'redirect': '/login.html' }) } try { await loginAccount(req, res, next); } catch (err) { return next(err); } }