Support the ongoing development of Laravel.io →
Authentication Security Database
Last updated 2 years ago.
0

I recommend you to use https://github.com/cartalyst/sentry/

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

}

Last updated 2 years ago.
0

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.
}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ammine007 ammine007 Joined 1 Apr 2014

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.

© 2024 Laravel.io - All rights reserved.