|
@@ -23,7 +23,7 @@ import zipfile
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
from types import ModuleType
|
|
from types import ModuleType
|
|
-from typing import Any, Callable, List, NamedTuple, Optional
|
|
|
|
|
|
+from typing import Callable, List, NamedTuple, Optional
|
|
from urllib.parse import urlparse
|
|
from urllib.parse import urlparse
|
|
|
|
|
|
import httpx
|
|
import httpx
|
|
@@ -2025,38 +2025,3 @@ def get_user_tier():
|
|
if authenticated_token[0]
|
|
if authenticated_token[0]
|
|
else "anonymous"
|
|
else "anonymous"
|
|
)
|
|
)
|
|
-
|
|
|
|
-
|
|
|
|
-def check_config_option_in_tier(
|
|
|
|
- option_name: str,
|
|
|
|
- allowed_tiers: list[str],
|
|
|
|
- fallback_value: Any,
|
|
|
|
- help_link: str | None = None,
|
|
|
|
-):
|
|
|
|
- """Check if a config option is allowed for the authenticated user's current tier.
|
|
|
|
-
|
|
|
|
- Args:
|
|
|
|
- option_name: The name of the option to check.
|
|
|
|
- allowed_tiers: The tiers that are allowed to use the option.
|
|
|
|
- fallback_value: The fallback value if the option is not allowed.
|
|
|
|
- help_link: The help link to show to a user that is authenticated.
|
|
|
|
- """
|
|
|
|
- config = get_config()
|
|
|
|
- current_tier = get_user_tier()
|
|
|
|
-
|
|
|
|
- if current_tier == "anonymous":
|
|
|
|
- the_remedy = (
|
|
|
|
- "You are currently logged out. Run `reflex login` to access this option."
|
|
|
|
- )
|
|
|
|
- else:
|
|
|
|
- the_remedy = (
|
|
|
|
- f"Your current subscription tier is `{current_tier}`. "
|
|
|
|
- f"Please upgrade to {allowed_tiers} to access this option. "
|
|
|
|
- )
|
|
|
|
- if help_link:
|
|
|
|
- the_remedy += f"See {help_link} for more information."
|
|
|
|
-
|
|
|
|
- if current_tier not in allowed_tiers:
|
|
|
|
- console.warn(f"Config option `{option_name}` is restricted. {the_remedy}")
|
|
|
|
- setattr(config, option_name, fallback_value)
|
|
|
|
- config._set_persistent(**{option_name: fallback_value})
|
|
|