Quantcast
Channel: Login only if user is active using Laravel - Stack Overflow
Viewing all articles
Browse latest Browse all 25

Answer by Can Celik for Login only if user is active using Laravel

$
0
0

You don't have to override the whole function. You can just change the Validator in AuthController to achieve that adding "exists:table,column" validation.

Let's assume that you have a users table with email,password and active fields.

'email' =>'exists:users,email,active,1'

Here is the validotor function should look like in AuthController.php

protected function validator(array $data){    return Validator::make($data, ['email' => 'required|email|max:255|exists:users,email,active,1','password' => 'required|confirmed'    ]);}

or if you are using soft deletes this should work too.

'email' =>'exists:users,email,deleted_at,NULL'

You can also check out the validation rule at this link http://laravel.com/docs/5.1/validation#rule-exists


Viewing all articles
Browse latest Browse all 25

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>