Making login screen a bit clearer

This commit is contained in:
Ian Roddis committed 2026-07-16 22:10:36 -03:00
1 parent 1180694738
commit 0150c19b75
3 files changed
+74 -17

No files matched your search

+38
View File
@@ -607,6 +607,44 @@ textarea:focus {
margin-bottom: 0.75rem; margin-bottom: 0.75rem;
} }
.local-login-panel {
margin-top: 1.25rem;
border-top: 1px solid var(--border);
padding-top: 1rem;
}
.local-login-panel summary {
cursor: pointer;
color: var(--muted);
font-size: 0.875rem;
user-select: none;
list-style: none;
display: flex;
align-items: center;
gap: 0.4rem;
}
.local-login-panel summary::-webkit-details-marker { display: none; }
.local-login-panel summary::before {
content: '›';
font-size: 1.1em;
transition: transform 0.15s;
display: inline-block;
}
.local-login-panel[open] summary::before {
transform: rotate(90deg);
}
.local-login-panel summary:hover {
color: var(--text);
}
.local-login-panel form {
margin-top: 1rem;
}
/* ─── Light theme ────────────────────────────────────────────────────────── */ /* ─── Light theme ────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: light) { @media (prefers-color-scheme: light) {
:root { :root {
+34 -14
View File
@@ -2,10 +2,41 @@
{% block title %}Sign in · {{ app_name }}{% endblock %} {% block title %}Sign in · {{ app_name }}{% endblock %}
{% block body %} {% block body %}
<div class="auth-shell"> <div class="auth-shell">
<form class="card auth-card" method="post" action="/login"> <div class="card auth-card">
<h1>{{ app_name }}</h1> <h1>{{ app_name }}</h1>
<p class="muted">Sign in to continue</p> <p class="muted">Sign in to continue</p>
{% if error %}<div class="alert">{{ error }}</div>{% endif %}
{% if ldap_enabled %}
<form method="post" action="/login/ldap">
{% if ldap_error %}<div class="alert">{{ ldap_error }}</div>{% endif %}
<label>Username
<input type="text" name="username" value="{{ username or '' }}" required autofocus>
</label>
<label>Password
<input type="password" name="password" required>
</label>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
<details class="local-login-panel" {% if local_error %}open{% endif %}>
<summary>Use a local account instead</summary>
<form method="post" action="/login">
{% if local_error %}<div class="alert">{{ local_error }}</div>{% endif %}
<label>Email
<input type="email" name="email" value="{{ email or '' }}" required>
</label>
<label>Password
<input type="password" name="password" required>
</label>
<button type="submit" class="btn btn-primary">Sign in with local account</button>
</form>
</details>
{% else %}
<form method="post" action="/login">
{% if local_error %}<div class="alert">{{ local_error }}</div>{% endif %}
<label>Email <label>Email
<input type="email" name="email" value="{{ email or '' }}" required autofocus> <input type="email" name="email" value="{{ email or '' }}" required autofocus>
</label> </label>
@@ -15,18 +46,7 @@
<button type="submit" class="btn btn-primary">Sign in</button> <button type="submit" class="btn btn-primary">Sign in</button>
</form> </form>
{% if ldap_enabled %}
<form class="card auth-card" method="post" action="/login/ldap">
<h2>Sign in with LDAP</h2>
<p class="muted">Use your directory username and password</p>
<label>Username
<input type="text" name="username" value="{{ username or '' }}" required>
</label>
<label>Password
<input type="password" name="password" required>
</label>
<button type="submit" class="btn btn-primary">Sign in with LDAP</button>
</form>
{% endif %} {% endif %}
</div> </div>
</div>
{% endblock %} {% endblock %}
+2 -3
View File
@@ -50,12 +50,11 @@ async def login_submit(
): ):
user = await user_crud.authenticate(db, email, password) user = await user_crud.authenticate(db, email, password)
if user is None: if user is None:
# Re-render the form with an error (HTMX swaps the form partial).
return templates.TemplateResponse( return templates.TemplateResponse(
request, request,
"login.html", "login.html",
{ {
"error": "Incorrect email or password", "local_error": "Incorrect email or password",
"email": email, "email": email,
"ldap_enabled": settings.ldap_enabled, "ldap_enabled": settings.ldap_enabled,
}, },
@@ -82,7 +81,7 @@ async def login_ldap_submit(
request, request,
"login.html", "login.html",
{ {
"error": "LDAP sign-in failed", "ldap_error": "Incorrect username or password",
"username": username, "username": username,
"ldap_enabled": True, "ldap_enabled": True,
}, },