4

I have written code for email verification. I want to change my login controller behavior so that it will only allow verified users only.

I have status field in database that will store user is verified or not by storing 0/1. Now on login request I have to check email, password, as well as status code is equal to 1. If verified, the user will be redirected to dashboard otherwise redirect to login with error message.

I have done all email verification things.

Please let me know what inputs you want.

amphetamachine
  • 27,620
  • 12
  • 60
  • 72
Pranav Mandlik
  • 644
  • 6
  • 19
  • 45

2 Answers2

2

Update your LoginController

need to write following function there

protected function authenticated($request, $user){

    if(!$user->is_active){
        //logic here 

    }
}

In above example, is_active is your table attribute where you have user status...!!

Ramzan Mahmood
  • 1,881
  • 2
  • 21
  • 46
2

There is a more elegant solution for this provided by BrokenBinary, which checks if the account is active or not while authentication, and returns a custom error message if account is inactive.

sykez
  • 2,015
  • 15
  • 14