Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pjblitz86 committed Jan 23, 2019
1 parent 5e4f978 commit 0caef69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ exports.login = function (req, res) {
if (!isValid) {
return res.status(400).json(errors);
}
const email = req.body.email;
const password = req.body.password;
const { email, password } = req.body;
User.findOne({ email })
.then(user => {
if (!user) {
Expand All @@ -67,6 +66,7 @@ exports.login = function (req, res) {
bcrypt.compare(password, user.password)
.then(isMatch => {
if (isMatch) {
// user passed, generate token
const payload = { id: user.id, name: user.name, avatar: user.avatar };
jwt.sign(
payload,
Expand Down

0 comments on commit 0caef69

Please sign in to comment.