login event handling in laravel 5

后端 未结 8 2519
温柔的废话
温柔的废话 2020-12-05 11:46

i am trying to hook to the login even in my L5 app to set last login time and IP address. i can make it work with the following:

Event::listen(\'auth.login\'         


        
8条回答
  •  一向
    一向 (楼主)
    2020-12-05 11:50

    In laravel 5.2; auth.login won't work... the following will have to be used:

    protected $listen = [
        'Illuminate\Auth\Events\Attempting' => [
            'App\Listeners\LogAuthenticationAttempt',
        ],
    
        'Illuminate\Auth\Events\Login' => [
            'App\Listeners\LogSuccessfulLogin',
        ],
    
        'Illuminate\Auth\Events\Logout' => [
            'App\Listeners\LogSuccessfulLogout',
        ],
    
        'Illuminate\Auth\Events\Lockout' => [
            'App\Listeners\LogLockout',
        ],
    ];
    

    As stated in the documentation here

提交回复
热议问题