php - Laravel 5.1 - Authenticate Username, Password AND if confirmed = 1 -


pulling hair out on seems simple task. use username instead of email in authcontroller using following code:

/**  * set login system use username instead of email address  * @var string  */ protected $username = 'username'; 

this has worked fine long time (when wasn't planning on users activating accounts). however, need users activate accounts, know need additional checks on login before can see dashboard.

i have modified postlogin() method below, thought correct:

public function postlogin(request $request) {     $this->validate($request, [         'username' => 'required', 'password' => 'required',     ]);      $credentials = $request->only('username', 'password');     $credentials = array_add($credentials, 'confirmed', '1');      if ($this->auth->attempt($credentials, $request->has('remember')))     {         return redirect()->intended($this->redirectpath());     }      return redirect($this->loginpath())                 ->withinput($request->only('username', 'remember'))                 ->witherrors([                     'username' => $this->getfailedloginmessage(),                 ]); } 

but following error:

undefined property: app\http\controllers\auth\authcontroller::$auth

what i'm doing wrong?

andy

just 1 glitch see there.

if ($this->auth->attempt($credentials, $request->has('remember')))

should be

if (auth::attempt($credentials, $request->has('remember')))


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -