Support the ongoing development of Laravel.io →
Authentication Security Database

I need to let users resgister themselves through a form, and let them inactive users till, the Administrator change their active field or whatever to 1

What are the steps to do that ?

User Model ? a boolean 'active' field in the users migration ? Where and how to call the next code found in the documentation page?

if (Auth::attempt(array('email' => $email, 'password' => $password, 'active' => 1))) { // The user is active, not suspended, and exists. } Or should i use sentry ? and forget about the basic built in laravel auth ? please help with this

Last updated 3 years ago.
0

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

Last updated 3 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 3 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 3 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 3 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.

© 2025 Laravel.io - All rights reserved.