Skip to content

Commit

Permalink
try refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjford committed Aug 2, 2019
1 parent 9d3bf06 commit 6a201cf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/models/AccountModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ const AccountModel = {
status: "Not Found", message: "Account not found for provided email"};
}

const passwordIsCorrect = bcrypt.compareSync(req.body.password, user.password);
if (!passwordIsCorrect) {
if (!await validPassword(user, req.body.password)) {
return {status: "Unauthorized", message: "Password not valid"};
}

Expand All @@ -36,6 +35,10 @@ const AccountModel = {
};
},

async validPassword(user, password) {
return bcrypt.compareSync(password, user.password);
},

async validateAccount(req) {
const query = `SELECT v.*, a.*
FROM verification_tokens v
Expand Down

0 comments on commit 6a201cf

Please sign in to comment.