Today, will share about how to reset your account in Laravel application from an API.
This is assumed you already setup JWT Auth in your Laravel app.
Create a new API controller –
php artisan make:controller Api/Auth/ForgotPasswordController and copy paste the following code, and add the forgot password route in
So, basically what I did was to use
Illuminate\Foundation\Auth\SendsPasswordResetEmails trait, which being used in the default Laravel Forgot Password Controller.
I just copy codes from
sendResetLinkEmail method, and make changes on how the response we should receive from an API.
Then you are done! Easy right? 🙂
To test, open up your email, you just need to pass email address – just like we did in Laravel Auth Scaffold, then you are done.
The email owner will receive reset password link, and the owner open up the email, click on the link, go reset as usual, as we did on web app.
That’s all, thanks!