Manually Sending The Reset Password Email
June 12, 2019
laravel 5.8
We needed an API call to request password so looking at laravel’s SendsPasswordResetEmails trait, we copied and did something like below:
// For this example, we placed this in our UserController
// don't forget to include the the Password facade
use Illuminate\Support\Facades\Password;
public function send_reset_api(Request $request) {
$email = $request->get('email');
$response = Password::broker()->sendResetLink( $email );
//we're using this for our API so we just returned 'status' instead of redirecting it
return $response == Password::RESET_LINK_SENT
? ['status' => true]
: ['status' => false];
}
//of course you need to put it in routes/web.php or routes/api.php...
Routes::post('/reset_login', 'UserController@send_reset_api');
From your API call, do a POST request to /reset_login with email address as input and you should be good