Auth routes
parent
81ede39ae9
commit
0025e28334
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.',
|
||||
|
|
Loading…
Reference in New Issue