RaZZeR RaZZeR - 4 months ago 64
PHP Question

Laravel Authentication Custom Rule

I'm working with laravel Auth. Trying to add new rule with email and password, if status(field in user model) is = 1 then he cannot login. I cannot find where should i add this. I was looking and middleware, guard.php AuthenticateUsers.php but did not found it..


You can try as:

if (Auth::attempt(['email' => $email, 'password' => $password, 'status' => 1])) {
    // The user is active, not suspended, and exists.

From the Docs

If you wish, you also may add extra conditions to the authentication query in addition to the user's e-mail and password.