diff --git a/src/api/tokens_cli.py b/src/api/tokens_cli.py index 287ac06..34072e6 100644 --- a/src/api/tokens_cli.py +++ b/src/api/tokens_cli.py @@ -2,10 +2,13 @@ import argparse import os import sys +from dotenv import load_dotenv + from src.api import tokens_db def main(argv=None, env=None) -> int: + load_dotenv() env = env if env is not None else os.environ parser = argparse.ArgumentParser(prog="python -m src.api.tokens_cli") sub = parser.add_subparsers(dest="cmd", required=True) diff --git a/src/app.py b/src/app.py index fdb5023..a2b5f72 100644 --- a/src/app.py +++ b/src/app.py @@ -262,37 +262,7 @@ def _auth_nav(_): if current_user.is_authenticated: email = current_user.email display = email if len(email) <= 30 else email[:27] + "..." - return dbc.DropdownMenu( - label=display, - nav=True, - in_navbar=True, - children=[ - dbc.DropdownMenuItem("Mon compte", href="/compte/admin"), - dbc.DropdownMenuItem( - html.Form( - method="POST", - action="/auth/logout", - style={"display": "inline"}, - children=[ - dcc.Input( - type="hidden", - id={"type": "csrf-input", "index": "navbar-logout"}, - name="csrf_token", - ), - html.Button( - "D\u00e9connexion", - type="submit", - className="btn btn-link p-0", - style={ - "textDecoration": "none", - "color": "inherit", - }, - ), - ], - ) - ), - ], - ) + return dbc.NavItem(dbc.NavLink(display, href="/compte/admin")) return dbc.NavItem(dbc.NavLink("Connexion", href="/connexion")) diff --git a/src/assets/css/style.css b/src/assets/css/style.css index 78f1466..9ea4e78 100644 --- a/src/assets/css/style.css +++ b/src/assets/css/style.css @@ -195,6 +195,12 @@ p.version > a { text-wrap: wrap; } +/* Account form */ + +input[type="email"] { + max-width: 400px; +} + /* --- Dashboard inputs --- */ .Select--multi .Select-value { diff --git a/src/pages/_compte_shell.py b/src/pages/_compte_shell.py index 96cafa9..8e20242 100644 --- a/src/pages/_compte_shell.py +++ b/src/pages/_compte_shell.py @@ -70,12 +70,39 @@ def account_guard(path: str, require_subscription: bool): return dcc.Location(href=href, id="compte-guard-redirect") if href else None +def _logout_item(): + return dbc.NavItem( + html.Form( + method="POST", + action="/auth/logout", + children=[ + dcc.Input( + type="hidden", + id={"type": "csrf-input", "index": "sidebar-logout"}, + name="csrf_token", + ), + html.Button( + "Déconnexion", + type="submit", + className="nav-link", + style={ + "background": "none", + "border": "none", + "width": "100%", + "textAlign": "left", + }, + ), + ], + ) + ) + + def _nav(active: str): links = [ dbc.NavLink(s["label"], href=s["href"], active=(s["key"] == active)) for s in visible_sections(current_user_has_subscription()) ] - return dbc.Nav(links, vertical=True, class_name="account-nav") + return dbc.Nav(links + [_logout_item()], vertical=True, class_name="account-nav") def account_shell(active: str, contenu):