Customise Laravel auth middleware

Viewed 7815

In my users table, I have a column rank which corresponds to the permissions of users. If rank > 0, the user may log in and proceed, since 0 in rank means they're (temporarily) blocked or inactive. So what I'd need is to customise the auth middleware so only rank > 0 are going to be authenticated whatsoever.

I did some research on it but didn't find where to put my code exactly.

EDIT: I earlier found how to manually authenticate a user featuring additional requirements (e.g. rank > 0), however, I'm using laravels built-in feature, so that doesn't help much:

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

(it's active in this case (source: laravel documentation), but could be adjusted).

2 Answers
Related