This is a pretty standard login and validation feature that works well. But I also want to check that the user is active. I set a column in my user table with an “active” value of 0 or 1.
public function post_login() { $input = Input::all(); $rules = array( 'email' => 'required|email', 'password' => 'required', ); $validation = Validator::make($input, $rules); if ($validation->fails()) { return Redirect::to_route('login_user') ->with_errors($validation->errors)->with_input(); } $credentials = array( 'username' => $input['email'], 'password' => $input['password'], ); if (Auth::attempt($credentials)) { // Set remember me cookie if the user checks the box $remember = Input::get('remember'); if ( !empty($remember) ) { Auth::login(Auth::user()->id, true); } return Redirect::home(); } else { return Redirect::to_route('login_user') ->with('login_errors', true); } }
I already tried something like this:
$is_active = Auth::user()->active; if (!$is_active == 1) { echo "Account not activated"; }
But this can only be used in the "auth try" if statement, and at that moment user credentials (email and pass) are already checked. Therefore, even if the user account, if it is not active at the moment, is already registered.
I need a way to return validation in order to tell them that they still need to activate their account and check if their account is set at the same time as checking their email and badges.
source share