I'm working on my Laravel Project and trying to override the default postLogin() from AuthenticatesAndRegistersUsers . So I have updated my AuthController and added this to override the built-in login,
public function postLogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email', 'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if ($this->auth->attempt($credentials, $request->has('remember')))
{
/* Check if the user is Activated */
$userID = \Auth::user()->id;
$user = new \App\User;
$result = $user->isUserActivated($userID);
if($result[0]->status == 1)
{
return redirect()->intended($this->redirectPath());
}
else if($result[0]->status == 0)
{
Session::flash('alert-danger', 'Your account is not yet Activated.');
return Redirect::to('auth/login');
}
}
return redirect($this->loginPath())
->withInput($request->only('email', 'remember'))
->withErrors([
'email' => $this->getFailedLoginMessage(),
]);
}
As you can see I have $result[0]->status which tells if the user is activated, if not then I will redirect them back to auth/login. I tried to var_dump($result[0]->status); and it is working fine and also means I override that it coz it's displaying it but my problem is instead of redirecting it to auth/login it is still going thru home and can login even if the status is 0. Seems I'm it's my override doesn't work, but when I var_dump $result[0]->status, it shows. Did i missed something?