Minor fixes on login (#4234)

* block logout

* fix default behaviour to no ask for creds

* enables to use --login on
Welcome to OpenBB Terminal v2.3.1
╭─────────────────────────────────── Home ───────────────────────────────────╮
│                                                                            │
│ Information, guides and support for the OpenBB Terminal:                   │
│     intro              introduction on the OpenBB Terminal                 │
│     about              discover the capabilities of the OpenBB Terminal (h │
│     support            pre-populate a support ticket for our team to evalu │
│     survey             fill in our 2-minute survey so we better understand │
│     update             attempt to update the terminal automatically (GitHu │
│     wiki               search for an expression in Wikipedia (https://www. │
│     news               display news articles based on term and data source │
│                                                                            │
│ Configure your own terminal:                                               │
│ >   keys               set API keys and check their validity               │
│ >   featflags          enable and disable feature flags                    │
│ >   sources            select your preferred data sources                  │
│ >   settings           tune settings (export folder, timezone, language, p │
│                                                                            │
│ Record and execute your own .openbb routine scripts:                       │
│     record             start recording current session                     │
│     stop               stop session recording and convert to .openbb routi │
│     exe                execute .openbb routine scripts (use exe --example  │
│                                                                            │
│ Main menu:                                                                 │
│ >   stocks             access historical pricing data, options, sector and │
│ >   crypto             dive into onchain data, tokenomics, circulation sup │
│ >   etf                exchange traded funds. Historical pricing, compare  │
│ >   economy            global macroeconomic data, e.g. futures, yield, tre │
│ >   forex              foreign exchanges, quotes, forward rates for curren │
│ >   futures            commodities, bonds, index, bitcoin and forex        │
│ >   alternative        alternative datasets, such as COVID and open source │
│ >   funds              mutual funds search, overview, holdings and sector  │
│                                                                            │
│ OpenBB Toolkits:                                                           │
│ >   econometrics       statistical and quantitative methods for relationsh │
│ >   forecast           timeseries forecasting with machine learning        │
│ >   portfolio          perform portfolio optimization and look at portfoli │
│ >   dashboards         interactive dashboards using voila and jupyter note │
│ >   reports            customizable research reports through jupyter noteb │
│                                                                            │
╰─────────────────────────────── OpenBB Terminal v2.3.1 (https://openbb.co) ─╯
You are using the latest stable version

2023 Feb 14, 06:39 (🦋) / $

[h] help menu    [q] return to previous menu    [e] exit terminal    [cmd -h] s
                                                                               e
                            2023 Feb 14, 06:39 (🦋) / $
The OpenBB Terminal is the result of a strong community building an investment research platform for everyone, anywhere.

We are always eager to welcome new contributors and you can find our open jobs here:
https://www.openbb.co/company/careers#open-roles

Join us           : https://openbb.co/discord
Follow us         : https://twitter.com/openbb_finance
Ask support       : https://openbb.co/support
Request a feature : https://openbb.co/request-a-feature

Fill in our 2-minute survey so we better understand how we can improve the OpenBB Terminal at https://openbb.co/survey

In the meantime access investment research from your chatting platform using the OpenBB Bot
Try it today, for FREE: https://openbb.co/products/bot

* reverting the condition to the original state

* openbb to match python terminal.py

* adding unauthorized

* reverting changes

* getting the value of the status

---------

Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
This commit is contained in:
Henrique Joaquim
2023-02-15 14:55:22 +00:00
committed by GitHub
parent 012561934c
commit 46b230f146
5 changed files with 20 additions and 9 deletions

View File

@@ -98,7 +98,8 @@ def strtobool(val):
def load_dotenv_and_reload_configs():
"""Loads the dotenv files in the following order:
"""
Loads the dotenv files in the following order:
1. Repository .env file
2. Package .env file
3. User .env file

View File

@@ -53,15 +53,14 @@ def login(
session = Local.get_session()
if not session:
console.print("No local session found. Creating new session.")
session = get_session(email, password, token, keep_session)
else:
console.print("Using saved session to login.")
console.print("Using local session to login.")
if session_model.login(session) in [
session_model.LoginStatus.FAILED,
session_model.LoginStatus.NO_RESPONSE,
]:
raise Exception("Login failed.")
status = session_model.login(session)
if status != session_model.LoginStatus.SUCCESS:
raise Exception(f"Login failed with status `{status.value}`.")
console.print("[green]Login successful.[/green]")

View File

@@ -22,6 +22,7 @@ class LoginStatus(Enum):
SUCCESS = "success"
FAILED = "failed"
NO_RESPONSE = "no_response"
UNAUTHORIZED = "unauthorized"
def create_session(email: str, password: str, save: bool) -> dict:
@@ -84,6 +85,8 @@ def login(session: dict) -> LoginStatus:
else None
)
return LoginStatus.SUCCESS
if response.status_code == 401:
return LoginStatus.UNAUTHORIZED
return LoginStatus.FAILED
return LoginStatus.NO_RESPONSE

3
pyproject.toml vendored
View File

@@ -7,13 +7,14 @@ authors = ["Didier Rodrigues Lopes"]
packages = [
{ include = "openbb_terminal" },
]
include = ["terminal.py"]
readme = "website/content/sdk/quickstart/installation.md"
homepage = "https://openbb.co"
repository = "https://github.com/OpenBB-finance/OpenBBTerminal"
documentation = "https://docs.openbb.co/sdk"
[tool.poetry.scripts]
openbb = 'openbb_terminal.terminal_controller:parse_args_and_run'
openbb = 'terminal:main'
[tool.poetry.dependencies]
python = "^3.8,<3.11, !=3.9.7"

View File

@@ -4,7 +4,10 @@ import sys
from openbb_terminal.base_helpers import load_dotenv_and_reload_configs
from openbb_terminal.terminal_helper import is_auth_enabled
if __name__ == "__main__":
# pylint: disable=import-outside-toplevel
def main():
multiprocessing.freeze_support()
sent_args = sys.argv[1:]
@@ -21,3 +24,7 @@ if __name__ == "__main__":
session_controller.main()
else:
session_controller.launch_terminal()
if __name__ == "__main__":
main()