token of email? Don't know what you mean?
Mar 3, 2017
3
Level 15
Verify Password Reset on hash_hmac
How does the laravel match the token on the email and token of password reset table for a given user. Because on email and token of password_reset table is different.
Level 1
In Illuminate\Auth\Passwords\DatabaseTokenRepository.php you can see that the token is generated with hmac:
hash_hmac('sha256', Str::random(40), $this->hashKey);
Then it is encrypted and saved in the database with password_hash function:
$hash = password_hash($value, PASSWORD_BCRYPT, [
'cost' => $this->cost($options),
]);
So even if someone has access to database can't find the actual reset token. When a user clicks on the reset link laravel takes the token and encrypts it using password_hash and searches it against the password_reset table and finds the user email.
Please or to participate in this conversation.