February 2019
Intermediate to advanced
204 pages
4h 52m
English
To authenticate a user, we need to implement an endpoint. Follow these steps to implement the authentication process:
router.post('/users/signin', User.signin);
signin: (req, res) => { Model.users .authenticate(req.body.user) .then(user => handleSuccess(res, { user })) .catch(errors => handleFailure(res, { errors, message: errors.message, status: 401 }), ); },
Schema.statics.authenticate = function(params = {}) { return new Promise((resolve, reject) => { try { const emptries = ['email', 'password'].filter(key => [undefined].includes(params[key]), ...Read now
Unlock full access