Laravel 5.2 : Do something after user has logged in?

后端 未结 6 2169
时光说笑
时光说笑 2020-12-18 18:07

(I\'m a beginner of Laravel)

I\'m using Laravel 5.2. I have successfully enabled the Authentication; by doing the php artisan make:auth

6条回答
  •  情话喂你
    2020-12-18 18:52

    For the post login, you can do that by modifying App/Http/Controllers/Auth/AuthController.php

    Add authenticated() into that class to override the default one:

    use Illuminate\Http\Request;
    
    protected function authenticated(Request $request, User $user) {
       // put your thing in here
    
       return redirect()->intended($this->redirectPath());
    }
    

    For the logout, add this function into the same class:

    use Auth;
    
    protected function getLogout()
    {
        Auth::logout();
    
        // do something here
    
        return redirect('/');
    }
    

提交回复
热议问题