Just create a boolean field in your users table called active, and set it to true for activated users. That line of code is what you use to authenticate users, so in your LoginController probably.
I am doing it like this.
public function postLogin() {
$credentials = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
if ( ! Auth::attempt($credentials) ) {
// return with error
}
if ( Auth::once($credentials) ) {
if ( ! Auth::user()->activated ) {
Auth::logout();
// return with error
}
}
// etc.
}
I copy and past below lines from laravel site,so I think this way is better.
Authenticating A User With Conditions
You also may add extra conditions to the authenticating query:
if (Auth::attempt(array('email' => $email, 'password' => $password, 'active' => 1)))
{
// The user is active, not suspended, and exists.
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community