How can we restrict deactivated users via Auth :: check in laravel 4.2
HI, I have implemented laravel login module using laravel authentication. I authenticated the user using Auth :: check and submitting the username, password in the Auth :: try method. And I have a status column in the users table.
How can I restrict Auth :: check to check only users with status 1?
+3
source to share
2 answers
Just make the status field one of the confirmations. You can do it:
$credentials = array(
'username' => $input['email'],
'password' => $input['password'],
'status' => 1
);
if (Auth::attempt($credentials))
{
// User status is 1 and password was correct
}
If you want to indicate to the user that they are inactive, you can follow this up:
if (Auth::validate(['username' => $input['email'], 'password' => $input['password'], 'status' => 0]))
{
return echo ('you are not active');
}
+6
source to share