php - Check another columns on login with default auth on Laravel 5 -


this first attempt @ using php framework, decided go laravel 5.

but have problem: want check user status @ login, enabled == 1 users login. checked authenticatesandregistersusers.php, , followed functions on guard.php, not understand check actual columns, , should place check column is_enabled.

some people won't agree me, i'd make own auth controller. default 1 obscure. if want can remove comes laravel php artisan fresh, remove auth controller , bunch of other things.

it quite simple make own, login method this:

public function login(request $request) {     $credentials = $request->only('email', 'password');     $remember = $request->get('remember') == 'on' ? true : false;      if(\auth::attempt($credentials, $remember)) {         $enabled = \auth::user()->enabled;          if(!$enabled) {             \auth::logout();             return redirect()->withmessage('user not enabled login');         }     } } 

check docs other authentication functions:

http://laravel.com/docs/5.0/authentication

you can check user in db before attempting:

$enabled = user::where('email', '=', $email)->first()->enabled; if($enabled && \auth::attempt($credentials, $remember)) {    ... redirect logged in page. 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -