Skip to content

Commit

Permalink
Merge pull request danielfsousa#16 from gkatsanos/patch-1
Browse files Browse the repository at this point in the history
You need to use await when consuming the return value of an async function
  • Loading branch information
danielfsousa authored Oct 4, 2017
2 parents f5af49c + 7a93b38 commit ba7d423
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/api/models/user.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ userSchema.method({
},

async passwordMatches(password) {
const matches = await bcrypt.compare(password, this.password);
return matches;
return bcrypt.compare(password, this.password);
},
});

Expand Down Expand Up @@ -155,7 +154,7 @@ userSchema.statics = {
isPublic: true,
};
if (password) {
if (user && user.passwordMatches(password)) {
if (user && await user.passwordMatches(password)) {
return { user, accessToken: user.token() };
}
err.message = 'Incorrect email or password';
Expand Down

0 comments on commit ba7d423

Please sign in to comment.