Support the ongoing development of Laravel.io →
Authentication

Hi all, I'm struggling in implementing disable user functionality. The only thing i'm missing is how to not to login the user if it's disabled (it's a property of the user model).

Apparently the service provider injects an instance of Illuminate\Auth\Guard, so i don't know how to overwrite the attempt method and i don't know if it's the right way.

Please "illuminate" me :)

Last updated 3 years ago.
0

Auth::attempt accept an associative array with all element you want to check against model defined in auth config file.

You shouldn't override anything.

Auth::attempt(['username'=>'...', 'password'=>'...', 'disabled'=>false])

The only 'special' value in array passed to Auth::attempt is password because it will be automatically hashed, so you must pass it not hashed.

I don't know if disabled is a real field in database or an appended one. And I don't know if Auth::attempt works for appended attributes.

Last updated 9 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.