Check if a user is logged. Otherwise, an error is raised.
338383
def _check_logged_user(self):
        """"""
        if not self._env or not self._password or not self._login:
            raise error.InternalError("Login required")
136834
public function check()
	{
		if (is_null($this->user))
		{
			// Check session first, follow by cookie
			if ( ! $userArray = $this->session->get() and ! $userArray = $this->cookie->get())
			{
				return false;
			}

			// Now check our user is an array with two elements,
			// the username followed by the persist code
			if ( ! is_array($userArray) or count($userArray) !== 2)
			{
				return false;
			}

			list($id, $persistCode) = $userArray;

			// Let's find our user
			try
			{
				$user = $this->getUserProvider()->findById($id);
			}
			catch (UserNotFoundException $e)
			{
				return false;
			}

			// Great! Let's check the session's persist code
			// against the user. If it fails, somebody has tampered
			// with the cookie / session data and we're not allowing
			// a login
			if ( ! $user->checkPersistCode($persistCode))
			{
				return false;
			}

			// Now we'll set the user property on Sentry
			$this->user = $user;
		}

		// Let's check our cached user is indeed activated
		if ( ! $user = $this->getUser() or ! $user->isActivated())
		{
			return false;
		}
		// If throttling is enabled we check it's status
		if( $this->getThrottleProvider()->isEnabled())
		{
			// Check the throttle status
			$throttle = $this->getThrottleProvider()->findByUser( $user );

			if( $throttle->isBanned() or $throttle->isSuspended())
			{
				$this->logout();
				return false;
			}
		}

		return true;
	}
276380
def get_current_user():
    """"""
    thread_local = AutomatedLoggingMiddleware.thread_local
    if hasattr(thread_local, 'current_user'):
        user = thread_local.current_user
        if isinstance(user, AnonymousUser):
            user = None
    else:
        user = None

    return user
894
def error(self, *args):
        """"""
        if _canShortcutLogging(self.logCategory, ERROR):
            return
        errorObject(self.logObjectName(), self.logCategory,
            *self.logFunction(*args))
903671
private String isLoggedIn() throws RuntimeException {
        if(authManager != null && authManager.getUser() != null && authManager.getUser().getAuthToken() != null){
            return "CUSTOM " + authManager.getUser().getAuthToken();
        } else {
            throw new RuntimeException("User state error.");
        }
    }
940338
def hasUser(self):
        
        username = self.getUsername()
        if not username:
            return False
        user = api.get_user(username)
        return user is not None
696294
def log_error(self, msg):
        
        if self.__logger:
            self.__logger.error(msg)

        raise RuntimeError(msg)
456636
def check_security!
      if controller
        if cookies[:browser_id] != self.browser_id
          invalidate!
          Authie.config.events.dispatch(:browser_id_mismatch_error, self)
          raise BrowserMismatch, "Browser ID mismatch"
        end

        unless self.active?
          invalidate!
          Authie.config.events.dispatch(:invalid_session_error, self)
          raise InactiveSession, "Session is no longer active"
        end

        if self.expired?
          invalidate!
          Authie.config.events.dispatch(:expired_session_error, self)
          raise ExpiredSession, "Persistent session has expired"
        end

        if self.inactive?
          invalidate!
          Authie.config.events.dispatch(:inactive_session_error, self)
          raise InactiveSession, "Non-persistent session has expired"
        end

        if self.host && self.host != controller.request.host
          invalidate!
          Authie.config.events.dispatch(:host_mismatch_error, self)
          raise HostMismatch, "Session was created on #{self.host} but accessed using #{controller.request.host}"
        end
      end
    end
294641
public function checkIsAdmin()
    {
        $this->checkIsLogin();

        $user = new User($this->di->get("db"));
        $user = $user->getUser($this->di->get("session")->get("user"));

        if ($user->authority != "admin") {
            $views = [
                ["comment/admin/fail", [], "main"]
            ];
            $this->di->get("pageRenderComment")->renderPage([
                "views" => $views,
                "title" => "Not authorized"
            ]);
        }
    }
979192
public function isLogged()
    {
        if (is_null($this->logged)) {
            $this->logged = (bool)is_user_logged_in();
        }

        return $this->logged;
    }
859731
def _is_logged_in(self):
        
        # if the user has not logged in in 24 hours, relogin
        if not self._http._has_session() or datetime.utcnow() >= self._lastlogin + timedelta(hours=24):
            return self._login()
        else:
            return {}
889581
def find_user(session, username):
    """"""
    resp = _make_request(session, FIND_USER_URL, username)
    if not resp:
        raise VooblyError('user not found')
    try:
        return int(resp[0]['uid'])
    except ValueError:
        raise VooblyError('user not found')
175250
def user_logged_in=(logged_in_option)
      raise JSS::InvalidDataError, "user_logged_in options: #{USER_LOGGED_IN.join(', ')}" unless USER_LOGGED_IN.include? logged_in_option
      @reboot_options[:user_logged_in] = logged_in_option
      @need_to_update = true
    end
113715
def should_log(self, request, response):
        
        return self.logging_methods == '__all__' or request.method in self.logging_methods
601480
static function isEnabledAfterFailedLogin( $userID, $ignoreTrusted = false )
    {
        if ( !is_numeric( $userID ) )
            return true;

        $userObject = eZUser::fetch( $userID );
        if ( !$userObject )
            return true;

        $trustedUser = eZUser::isTrusted();
        // If user is trusted we should stop processing
        if ( $trustedUser and !$ignoreTrusted )
            return true;

        $maxNumberOfFailedLogin = eZUser::maxNumberOfFailedLogin();

        if ( $maxNumberOfFailedLogin == '0' )
            return true;

        $failedLoginAttempts = $userObject->failedLoginAttempts();
        if ( $failedLoginAttempts > $maxNumberOfFailedLogin )
            return false;

        return true;
    }
1173030
def onUserError(self, fail, message):
        
        self.log.error(fail)
        self.log.error(message)
325338
static function is_error( $emask = null ) {
		if( $emask === null ){
			return (bool) self::get_global_level();
		}	
		else {
			return (bool) ( self::get_global_level() & $emask );
		}
	}