middleware('guest', ['except' => 'logout']); } /** * Returns field name to use at login. * * @return string */ public function username() { return config('auth.providers.users.field','email'); } /** * Attempt to log the user into the application. * * @param \Illuminate\Http\Request $request * @return bool */ protected function attemptLogin(Request $request) { if ($this->username() === 'email') return $this->attemptLoginAtAuthenticatesUsers($request); if ( ! $this->attemptLoginAtAuthenticatesUsers($request)) { return $this->attempLoginUsingUsernameAsAnEmail($request); } return false; } /** * Attempt to log the user into application using username as an email. * * @param \Illuminate\Http\Request $request * @return bool */ protected function attempLoginUsingUsernameAsAnEmail(Request $request) { return $this->guard()->attempt( ['email' => $request->input('username'), 'password' => $request->input('password')], $request->has('remember')); } }