Auth routes

develop
sundowndev 2018-11-16 18:20:25 +01:00
parent 81ede39ae9
commit 0025e28334
3 changed files with 6 additions and 6 deletions

View File

@ -4,8 +4,8 @@ const register = require('./register');
const login = require('./login'); const login = require('./login');
const reset = require('./reset'); const reset = require('./reset');
const RegisterValidation = require.main.require('./app/validation/register'); const RegisterValidation = require.main.require('./app/validation/auth/register');
const LoginValidation = require.main.require('./app/validation/login'); const LoginValidation = require.main.require('./app/validation/auth/login');
/** /**
* @api {post} /auth/register Register * @api {post} /auth/register Register
@ -29,7 +29,7 @@ auth.post('/register', RegisterValidation, register);
* @apiParam {String} email email of the user. * @apiParam {String} email email of the user.
* @apiParam {String} password password 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); auth.post('/login', LoginValidation, login);

View File

@ -31,7 +31,7 @@ module.exports = (req, res, next) => {
const token = jwt.sign({ const token = jwt.sign({
user: dataUser, user: dataUser,
}, secret, { }, secret, {
expiresIn: '12h', expiresIn: '3h',
}); });
// return the information including token as JSON // return the information including token as JSON

View File

@ -13,8 +13,8 @@ module.exports = (req, res, next) => {
password: passwordHash, password: passwordHash,
}); });
UserModel.countDocuments({ email: req.body.email }, (err, c) => { UserModel.countDocuments({ email: req.body.email }, (err, count) => {
if (c !== 0) { if (count !== 0) {
return next({ return next({
status: 401, status: 401,
message: 'Email is already taken by another user.', message: 'Email is already taken by another user.',