Show email, company, stand in header, v1.0.5
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ from flask import Flask
|
||||
from routes.main import bp as main_bp
|
||||
from routes.api import bp as api_bp
|
||||
|
||||
VERSION = "1.0.4"
|
||||
VERSION = "1.0.5"
|
||||
|
||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
|
||||
|
||||
@@ -26,6 +26,23 @@ def _client_id(token):
|
||||
return ""
|
||||
|
||||
|
||||
def _token_info(token):
|
||||
import base64, json
|
||||
try:
|
||||
parts = token.split(".")
|
||||
if len(parts) >= 2:
|
||||
payload = base64.urlsafe_b64decode(parts[1] + "==")
|
||||
d = json.loads(payload)
|
||||
return {
|
||||
"email": d.get("email", ""),
|
||||
"company": d.get("company_name", ""),
|
||||
"client_id": d.get("ClientID", ""),
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
return {}
|
||||
|
||||
|
||||
@bp.route("/", methods=["GET", "POST"])
|
||||
def index():
|
||||
env_token = current_app.config["NUBES_API_TOKEN"]
|
||||
@@ -88,6 +105,7 @@ def index():
|
||||
env_token_masked=_mask(env_token),
|
||||
has_user_token=bool(user_token),
|
||||
client_id=_client_id(active_token),
|
||||
token_info=_token_info(active_token),
|
||||
instance_groups=instance_groups)
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<div style="max-width:900px;margin:0 auto;padding:12px 16px 0;display:flex;align-items:center;gap:12px;">
|
||||
<img src="{{ url_for('static', filename='logo.svg') }}" alt="Nubes" style="height:24px;" />
|
||||
<span style="font-size:11px;color:var(--muted);">v{{ config.VERSION if config else '?' }}</span>
|
||||
{% if token_info.email %}<span style="font-size:11px;color:var(--muted);">{{ token_info.email }} | {{ token_info.company }} | test</span>{% endif %}
|
||||
<span style="flex:1;"></span>
|
||||
<form method="post" style="display:flex;align-items:center;gap:6px;">
|
||||
<input type="password" name="token" placeholder="env: {{ env_token_masked }}" value="{{ '' if not has_user_token else '••••••••' }}" style="height:28px;width:200px;font-size:12px;border:1px solid var(--brand-gray);border-radius:4px;padding:0 6px;" />
|
||||
|
||||
Reference in New Issue
Block a user