def contactgroups_of_user(user_id: UserId) -> List[ContactgroupName]: user = load_cached_profile(user_id) if user is None: # No cached profile present. Load all users to get the users data user = load_users(lock=False).get(user_id, {}) assert user is not None # help mypy return user.get("contactgroups", [])
def _user_locked(user_id: UserId) -> bool: user = load_cached_profile(user_id) if user is None: # No cached profile present. Load all users to get the users data user = load_users(lock=False).get(user_id, {}) assert user is not None # help mypy return user.get('locked', False)
def _is_local_user(user_id: UserId) -> bool: user = load_cached_profile(user_id) if user is None: # No cached profile present. Load all users to get the users data user = load_users(lock=False).get(user_id, {}) assert user is not None # help mypy return user.get('connector', 'htpasswd') == 'htpasswd'
def _set_user_attribute(key: str, value: Optional[str]): assert config.user.id is not None user_id = config.user.id cached_profile = load_cached_profile(config.user.id) if cached_profile is None: raise MKUserError(None, _("Could not load cached user profile.")) cached_profile[key] = value save_cached_profile(user_id, cached_profile) userdb.save_custom_attr(user_id, key, value)
def _load_user(user_id: UserId) -> UserSpec: """Loads of a single user profile This is called during regular page processing. We must not load the whole user database, because that would take too much time. To optimize this, we have the "cached user profile" files which are read normally when working with a single user. """ user = load_cached_profile(user_id) if user is None: # No cached profile present. Load all users to get the users data user = load_users(lock=False).get(user_id, {}) assert user is not None # help mypy return user