Issue
I have a reset_password field within my users table that is set to '1' when a user account is created . When a user logs in I check this field and if set to '1' within an event. I want to redirect from the event if the field is set to '1'.
I have tried:
return redirect()->route('user/change_password');
and in my routes file I have set
Route::get('user/change_password', 'UserController@resetpasswordform');
but this returns an error of:
InvalidArgumentException in UrlGenerator.php line 306: Route [user/change_password] not defined.
I have also tried this
return redirect()->action('UserController@resetpasswordform');
but this is just ignores the redirect and logs the user in. I have set a dd('hello');
within the method but this does nothing.
I have tried changing the redirect for an authenticated user and if the field is not set to 1 then follows this redirect, but if the field is set to 1 it ignores this.
I am at a loss as to the route that this redirect is taking.
Solution
I copied the postLogin class to my AuthController and theredirect to the method
if (Auth::attempt($credentials, $request->has('remember'))) {
if(Auth::user()->reset_password=='1'){
return redirect()->action('UserController@resetpasswordform');
}
return $this->handleUserWasAuthenticated($request, $throttles);
}
Answered By - Barry Watts
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.