Reputation: 12331
Im editing my laravel auth in a way users need to activate theyr account by clicking a link in their mailbox. My database has an extra timestamp field 'activated_at'. How can I validate if 'activated_at' is not empty. I've found te following rule to customize Auth::
if (Auth::attempt(['email' => $email, 'password' => $password, 'active' => 1]))
{
}
But how should i add a rule to check for a value to be none empty?
Upvotes: 0
Views: 1381
Reputation: 40909
Laravel's user provider tries to load a user by searching for exact match between user data and data passed to Auth::attempt() - see implementation of \Illuminate\Auth\DatabaseUserProvider::retrieveByCredentials() or \Illuminate\Auth\EloquentUserProvider::retrieveByCredentials() depending which provider you are using. Therefore it is impossible to provide "where field not null" constraint to Auth::attempt().
You could solve that by implementing your own user provider but I don't think it's worth the effort. I suggest storing is_active flag in User model instead.
Upvotes: 1