I have a Laravel application that I am using to test the authentication that is created with php artisan make:auth
. To the migration that creates the users I have added a field to indicate if the user is active or not, like this:
...
$table->char('activo', 1)->default('S');
...
What I intend is that when a user enters his login and password, if it is not active (field activo
with value N
, for example), it will not let him access or even tell him that he cannot access because it has been deactivated.
The problem is that, as the methods are in such an elaborate framework, in different traits, and one method calls another, I cannot locate which method I have to override in the controller, much less how to do it.
Let's see if you can give me a clue. I have reviewed the traits AuthenticatesUsers.php
and ThrottlesLogins.php
. In the first one I have reviewed the method login()
, but the process is not clear (or I, at least, do not see it clearly).
Can you guide me?
To add additional fields to the Laravel authentication, you must resort to
credentials
the trait methodAuthenticatesUsers
, since if youLoginController
use said trait it would be enough to "overwrite" it in your ControllerThe value of
$this->username()
returns the default field with which the login process will do. (can also be overwritten, default value is email)LoginController