extend laravel 5 built-in authentication to login only “if user == active”

前端 未结 5 2111
春和景丽
春和景丽 2021-02-05 20:56

I use the included authentication of laravel 5.1.6 and want to know how I can extend it, to work like this:

if (Auth::attempt([\'email\' => $email, \'password         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-05 21:15

    On Laravel 5.3.* update app/Http/Controllers/Auth/LoginController

    class LoginController extends Controller
    {
    
        use AuthenticatesUsers;
    
        /**
         * Get the needed authorization credentials from the request.
         *
         * @param  \Illuminate\Http\Request  $request
         * @return array
         */
        protected function credentials(\Illuminate\Http\Request $request)
        {
            $credentials = $request->only($this->username(), 'password');
    
            return array_add($credentials, 'active', '1');
        }
    
        // your code here
    

提交回复
热议问题