diff --git a/app/routes/auth/index.js b/app/routes/auth/index.js index a70e6fc..7055587 100644 --- a/app/routes/auth/index.js +++ b/app/routes/auth/index.js @@ -4,8 +4,8 @@ const register = require('./register'); const login = require('./login'); const reset = require('./reset'); -const RegisterValidation = require.main.require('./app/validation/register'); -const LoginValidation = require.main.require('./app/validation/login'); +const RegisterValidation = require.main.require('./app/validation/auth/register'); +const LoginValidation = require.main.require('./app/validation/auth/login'); /** * @api {post} /auth/register Register @@ -29,7 +29,7 @@ auth.post('/register', RegisterValidation, register); * @apiParam {String} email email of the user. * @apiParam {String} password password of the user. * - * @apiSuccess {string} access_token Access token. + * @apiSuccess {String} access_token Access token. */ auth.post('/login', LoginValidation, login); diff --git a/app/routes/auth/login.js b/app/routes/auth/login.js index 76f303f..f250ce8 100644 --- a/app/routes/auth/login.js +++ b/app/routes/auth/login.js @@ -31,7 +31,7 @@ module.exports = (req, res, next) => { const token = jwt.sign({ user: dataUser, }, secret, { - expiresIn: '12h', + expiresIn: '3h', }); // return the information including token as JSON diff --git a/app/routes/auth/register.js b/app/routes/auth/register.js index 567116e..bdfc616 100644 --- a/app/routes/auth/register.js +++ b/app/routes/auth/register.js @@ -13,8 +13,8 @@ module.exports = (req, res, next) => { password: passwordHash, }); - UserModel.countDocuments({ email: req.body.email }, (err, c) => { - if (c !== 0) { + UserModel.countDocuments({ email: req.body.email }, (err, count) => { + if (count !== 0) { return next({ status: 401, message: 'Email is already taken by another user.',