hagopj13 / hagopj13/node-express-boilerplate

Missing await keyword in user.model.js

Open
#165 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

At line 73 in `user.model.js`, below function is written:

```javascript
userSchema.methods.isPasswordMatch = async function (password) {
const user = this;
return bcrypt.compare(password, user.password);
};
```

I believe there is a missing await keyword in return statement as the compare function is an async function. If bcrypt.compare doesn't return promise, then async is redundant.

So the final code should be
```javascript
userSchema.methods.isPasswordMatch = async function (password) {
const user = this;
return await bcrypt.compare(password, user.password);
};
```

Contributor guide

Open the contributing guide

Research direction

Open user.model.js at line 73 and verify bcrypt.compare's documented return behavior and the surrounding user-model usage. Confirm whether the async handling needs adjustment, then run the relevant project tests; done means the password-match method follows the library contract without changing its expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
authentication, backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.