Logging out other devices not working after overriding login function
I overrode the login function since I need to have the user login with their username/email. I also added invalidating session if ever they login to their account on another device. I followed Invalidating Session on other devices, added the line to authenticated function. Was there any code that was gone due to overriding the login function?
Here is my code:
protected function authenticated()
{
Auth::logoutOtherDevices(request('password'));
}
public function login(Request $request)
{
$this->validate($request, [
'login' => 'required',
'password' => 'required',
]);
$login_type = filter_var($request->input('login'), FILTER_VALIDATE_EMAIL )
? 'email'
: 'username';
$request->merge([
$login_type => $request->input('login')
]);
if (Auth::attempt($request->only($login_type, 'password'))) {
return redirect()->intended($this->redirectPath());
}
return redirect()->back()
->withInput()
->withErrors([
'login' => 'These credentials do not match our records.',
]);
}