1 month ago

Logging out other devices not working after overriding login function

Posted 1 month ago by zafercuz

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()

    public function login(Request $request)
        $this->validate($request, [
            'login'    => 'required',
            'password' => 'required',

        $login_type = filter_var($request->input('login'), FILTER_VALIDATE_EMAIL ) 
            ? 'email' 
            : 'username';

            $login_type => $request->input('login')

        if (Auth::attempt($request->only($login_type, 'password'))) {
            return redirect()->intended($this->redirectPath());

        return redirect()->back()
                'login' => 'These credentials do not match our records.',

Please sign in or create an account to participate in this conversation.