I am trying to override Laravel's default function for resetting passwords. Before I go ahead with resetting the password, I want to dynamically set $redirectTo based on certain user information, so that the user is properly redirected to a different page based on said info. However, when I go try to go through with it I end up at a completely white page with the path ".../password/reset". The user's password is being properly reset, but the redirect isn't working as intended.
My code is referenced below. What am I doing wrong?
ResetPasswordController.php
class ResetPasswordController extends Controller
{
use ResetsPasswords;
protected $redirectTo;
public function __construct()
{
$this->middleware('guest');
}
public function resetPasswordByUser(Request $request, Users $users)
{
$user = $users->findUserByEmail($request->input('email'));
if ($user->case == 1) {
$this->redirectTo = '/case1';
} elseif ($user->case == 2) {
$this->redirectTo = '/case2';
} elseif ($user->case == 3) {
$this->redirectTo = '/case3';
}
$this->reset($request);
}
}
web.php
Auth::routes();
.......
Route::post('/password/reset', 'Auth\ResetPasswordController@resetPasswordByUser');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire