Monday, 30 April 2018

Redirected after Login or Register

in Login Controller, it was located under Illuminate\Foundation\Auth\AuthenticatesUsers;

then change this function to :

  /**
     * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {
      return redirect('/admin');
    }


while for Register Controller, it was located under Illuminate\Foundation\Auth\RegistersUsers;

then change this function to : 

    /**
     * The user has been registered.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function registered(Request $request, $user)
    {
        return redirect('/admin');
    }

however RegisterController has a constant variable   protected $redirectTo = '/home'; which you can just change their value to your target url.

reference 

https://stackoverflow.com/questions/44173616/laravel-5-4-how-do-i-find-logincontrollershowloginform

https://stackoverflow.com/questions/42177044/laravel-5-4-redirection-to-custom-url-after-login

No comments:

Post a Comment