diff --git a/hbd/server/http.py b/hbd/server/http.py index 2867c4b..e564bc4 100644 --- a/hbd/server/http.py +++ b/hbd/server/http.py @@ -35,6 +35,10 @@ def _render_template(html_str: str, **context) -> str: SESSION_COOKIE = "hbd_session" +def _gitea_cfg_url(config: dict) -> str: + return config.get("oauth", {}).get("gitea", {}).get("url", "") + + def _get_token(request) -> str: """Extract session token from Bearer header, X-Auth-Token header, or cookie.""" auth = request.headers.get("Authorization", "") @@ -622,6 +626,16 @@ async def start( ) raise resp error = "Invalid username or password." + elif request.rel_url.query.get("error"): + error = "Sign-in failed. Please try again." + + gitea_button = "" + if oauth_mod.is_enabled(config): + gitea_button = f""" +
or
+ + Sign in with Gitea + """ html = f""" @@ -642,17 +656,23 @@ async def start( button:hover {{ background: #0055aa; }} .error {{ color: #c00; font-size: .9em; margin-bottom: .8em; }} .field {{ margin-bottom: .9em; }} + .divider {{ text-align: center; margin: 1.2em 0 .8em; color: #999; + font-size: .85em; border-top: 1px solid #eee; padding-top: .8em; }} + .gitea-btn {{ display: block; width: 100%; padding: .6em; background: #609926; + color: #fff; border-radius: 4px; font-size: 1em; text-align: center; + text-decoration: none; box-sizing: border-box; }} + .gitea-btn:hover {{ background: #4e7d1e; }}

Heartbeat

- {'

' + error + '

' if error else ''} + {'

Invalid username, password, or OAuth error.

' if error else ''}
-
+ {gitea_button}
"""