email; // try to find user $user = User::where('email', $email) ->where('role', '!=', User::ROLE_VISITOR) ->where('status', User::STATE_ACTIVE) ->first(); if (!$user) { return $this->loginFailed(); } // try to log in user if (Hash::check($request->password, $user->password)) { Auth::login($user); $redirect = $request->redirectTo ? $request->redirectTo : route('admin.dashboard'); return redirect()->intended($redirect); } // login invalid, redirect and inform the user return $this->loginFailed(); } /** * Logs out user * * @return \Illuminate\Http\RedirectResponse */ public function logout() { // remove user information \Auth::logout(); // redirect to login form with info about successfull logout return redirect() ->route('login') ->with('success', trans('admin/common.logoutSuccessfull')); } private function loginFailed() { return redirect() ->route('login') ->with('error', trans('auth.failed')) ->withInput(); } }