mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 21:42:22 +00:00
change user vars
This commit is contained in:
@@ -8,7 +8,7 @@ from openbb_terminal.core.config.paths import SETTINGS_DIRECTORY
|
||||
from openbb_terminal.rich_config import console
|
||||
from openbb_terminal import feature_flags as obbff
|
||||
from openbb_terminal.account.statics import BASE_URL, Success, Failure
|
||||
from openbb_terminal.account.user import User
|
||||
from openbb_terminal.account import user
|
||||
from openbb_terminal import config_terminal as cfg
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ def fetch_user_configs() -> Union[Success, Failure]:
|
||||
try:
|
||||
response = requests.get(
|
||||
url=BASE_URL + "terminal/user",
|
||||
headers={"Authorization": f"{User.token_type.title()} {User.token}"},
|
||||
headers={"Authorization": f"{user.TOKEN_TYPE.title()} {user.TOKEN}"},
|
||||
)
|
||||
if response.status_code == 200:
|
||||
User.configs = json.loads(response.content)
|
||||
user.CONFIGS = json.loads(response.content)
|
||||
return Success("[green]\nFetched user configurations.[/green]")
|
||||
return Failure("[red]\nFailed to fetch configurations.[/red]")
|
||||
except requests.exceptions.ConnectionError:
|
||||
@@ -30,12 +30,12 @@ def fetch_user_configs() -> Union[Success, Failure]:
|
||||
|
||||
def apply_configs():
|
||||
"""Apply configurations."""
|
||||
if User.configs:
|
||||
settings = User.configs.get("features_settings", {})
|
||||
if user.CONFIGS:
|
||||
settings = user.CONFIGS.get("features_settings", {})
|
||||
for k, v in settings.items():
|
||||
setattr(obbff, k, v)
|
||||
|
||||
keys = User.configs.get("features_keys", {})
|
||||
keys = user.CONFIGS.get("features_keys", {})
|
||||
for k, v in keys.items():
|
||||
setattr(cfg, k, v)
|
||||
|
||||
@@ -48,16 +48,16 @@ def load_user_info(login_info: dict):
|
||||
login_info : dict
|
||||
The login info.
|
||||
"""
|
||||
User.token_type = login_info.get("token_type", "")
|
||||
User.token = login_info.get("access_token", "")
|
||||
User.uuid = login_info.get("uuid", "")
|
||||
user.TOKEN_TYPE = login_info.get("token_type", "")
|
||||
user.TOKEN = login_info.get("access_token", "")
|
||||
user.UUID = login_info.get("uuid", "")
|
||||
|
||||
if User.token:
|
||||
decoded_info = jwt.decode(User.token, options={"verify_signature": False})
|
||||
User.email = decoded_info.get("sub", "")
|
||||
if user.TOKEN:
|
||||
decoded_info = jwt.decode(user.TOKEN, options={"verify_signature": False})
|
||||
user.EMAIL = decoded_info.get("sub", "")
|
||||
|
||||
if obbff.USE_FLAIR == ":openbb":
|
||||
username = User.email[: User.email.find("@")]
|
||||
username = user.EMAIL[: user.EMAIL.find("@")]
|
||||
setattr(obbff, "USE_FLAIR", "[" + username + "] 🦋")
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ from openbb_terminal.core.config.paths import SETTINGS_DIRECTORY
|
||||
from openbb_terminal.helper_funcs import system_clear
|
||||
from openbb_terminal.rich_config import console
|
||||
from openbb_terminal.account.statics import BASE_URL, Success, Failure
|
||||
from openbb_terminal.account.user import User
|
||||
from openbb_terminal.account import login_controller
|
||||
from openbb_terminal.account import login_controller, user
|
||||
|
||||
|
||||
def remote_logout() -> Union[Success, Failure]:
|
||||
@@ -21,7 +20,7 @@ def remote_logout() -> Union[Success, Failure]:
|
||||
if (
|
||||
requests.get(
|
||||
url=BASE_URL + "logout-everywhere",
|
||||
headers={"Authorization": f"{User.token_type.title()} {User.token}"},
|
||||
headers={"Authorization": f"{user.TOKEN_TYPE.title()} {user.TOKEN}"},
|
||||
).status_code
|
||||
== 200
|
||||
):
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class User:
|
||||
token_type: str = ""
|
||||
token: str = ""
|
||||
email: str = ""
|
||||
uuid: str = ""
|
||||
configs: Optional[dict] = None
|
||||
TOKEN_TYPE: str = ""
|
||||
TOKEN: str = ""
|
||||
EMAIL: str = ""
|
||||
UUID: str = ""
|
||||
CONFIGS: Optional[dict] = None
|
||||
|
||||
@@ -19,7 +19,7 @@ from prompt_toolkit.formatted_text import HTML
|
||||
from prompt_toolkit.styles import Style
|
||||
from rich.markdown import Markdown
|
||||
from openbb_terminal.account.logout_model import logout
|
||||
from openbb_terminal.account.user import User
|
||||
from openbb_terminal.account import user
|
||||
|
||||
from openbb_terminal.core.config.paths import (
|
||||
USER_CUSTOM_IMPORTS_DIRECTORY,
|
||||
@@ -686,8 +686,8 @@ class BaseController(metaclass=ABCMeta):
|
||||
ns_parser = self.parse_simple_args(parser, other_args)
|
||||
|
||||
if ns_parser:
|
||||
console.print(f"[info]email:[/info] {User.email}")
|
||||
console.print(f"[info]uuid:[/info] {User.uuid}\n")
|
||||
console.print(f"[info]email:[/info] {user.EMAIL}")
|
||||
console.print(f"[info]uuid:[/info] {user.UUID}\n")
|
||||
|
||||
@staticmethod
|
||||
def parse_simple_args(parser: argparse.ArgumentParser, other_args: List[str]):
|
||||
|
||||
Reference in New Issue
Block a user