RaZZeR RaZZeR - 1 year ago 123
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..

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download