Password Hard Reset

Password Hard Reset
Photo by NFT gallery / Unsplash

As it happens quite often to enforce by code, in a Laravel application, a password reset for a user (e.g. when manually creating a new user from the administration panel, and the new password has to be choosen by the user himself), and every time I have to dive into the internals to check how to do it, this is mostly a reminder for myself.

To do it, just call:

use Illuminate\Support\Facades\Password;

Password::broker()->sendResetLink(['email' => $user->email]);

This will call the internal Laravel code to retrieve the user with the given email, generate a token, save it in the proper table, and send the proper email.