title: bcrypt.compare always returns false
body: <p>I am trying to get a login function going but when I try to compare password with hashed password it always returns false</p>
  <p>This is my registerUser function that holds the hashing</p>
  <pre><code>const registerUser = async (request, response) =&gt; {
      const hashedPassword = await bcrypt.hash(request.body.password, 12)
      const user = new UserModel({
          username: request.body.username,
          password: hashedPassword
      });
  
      try {
          const databaseResponse = await user.save();
          response.status(201).send(databaseResponse);
      } catch (error) {
          response.status(500).send({message: error.message});
      }
  };
  </code></pre>
  <p>This is the login function that holds the compare</p>
  <pre><code>const login = async (request, response) =&gt; {
      try{
          const user = await UserModel.findOne({username: request.body.username})
          if(!user) return response.status(403).send('no user with name ' + request.body.username + ' found');
          const isPassValidated = await bcrypt.compare(request.body.password, user.password)
          if(!isPassValidated) return response.status(403).send('wrong password');
          response.status(200).send('yay');
      } catch(error){
          response.status(500).send({message: error.message});
      }
  }
  </code></pre>
  <p>When I console.log request.body.password and user.password the hashed string is equal to the unhashed string so it should return true</p>
  <p><a href="https://i.stack.imgur.com/9NqWJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9NqWJ.png" alt="screenshot" /></a></p>
  <p>The hashed string is the same string that is saved in the database</p>