Three complaints, one cause. Logging out could not finish because the session belonged to another server, whose logout is POST-only and unreachable from here. "Ese usuario ya está en uso" for somebody absent from Miembros, because erase_member deleted our row and left the git account standing — two stores of users, one of them showing. And the hand-off to a differently-designed domain, with a Forgot password that could never work. All three followed from delegating identity, so it is no longer delegated. Members now sign in at /comunidad/login against a scrypt hash in our own database, via werkzeug.security, which arrives with Flask. They have no account on the git server at all, which makes the collision impossible rather than fixed. Logout is one click. This removes more than it adds: the OAuth round trip, the client registration, tokens.py with its refresh-before-expiry logic, the gitea_tokens table, and the logged-out page that existed to apologise for a logout that did not log you out. The editor keeps per-writer attribution without per-writer tokens: one CONTENT_TOKEN commits, and each commit names its author, which Gitea's contents API supports and a test now asserts. CONTENT_TOKEN falls back to GITEA_ADMIN_TOKEN so nothing breaks on deploy, but it only needs write access to one repository, while the admin token can modify every account on the instance — and now has no remaining job. The refusals are the interesting part. Unknown name, wrong password, suspended member and invited-but-never-arrived all answer identically, asserted by comparing the rendered bytes. The hash check runs against a decoy even when there is no such member, so an unknown name does not answer faster. Attempts are rate limited, counted inside SQLite for the reason invites.py documents. A NULL hash never matches anything. Migration 2 adds password_hash and drops the dead OAuth tokens. Everyone starts NULL, including the owner, so scripts/set-password.sh exists and was tested before this could ship: it prompts without echo, never takes the password as an argument where ps would show it, and refuses a short one or an unknown member. Rehearsed against a rebuilt copy of the server's database: starts, keeps the photo, drops the tokens table, serves a login form with no redirect, signs in, signs out, stays out. 223 tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
49 lines
1.7 KiB
HTML
49 lines
1.7 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Dar de alta{% endblock %}
|
|
|
|
{% block main %}
|
|
<form class="card" method="post" action="{{ url_for('members.new') }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<h1>Dar de alta a alguien</h1>
|
|
|
|
<label for="login">Usuario</label>
|
|
<input id="login" name="login" required pattern="[A-Za-z0-9][A-Za-z0-9._\-]*"
|
|
placeholder="maria.lopez">
|
|
<p class="muted small">Letras, números, punto, guion y guion bajo.</p>
|
|
|
|
<label for="display_name">Nombre</label>
|
|
<input id="display_name" name="display_name" placeholder="María López">
|
|
|
|
<label for="email">Correo</label>
|
|
<input id="email" name="email" type="email" required
|
|
placeholder="maria@ejemplo.com">
|
|
<p class="muted small">Ahí llega la invitación para elegir contraseña.</p>
|
|
|
|
{% if not can_send_mail %}
|
|
{# Not an error: the account is still created and the invitation still
|
|
issued. But it leaves by hand, and finding that out after filling the
|
|
form is how an invitation ends up believed sent and never delivered. #}
|
|
<p class="muted small">
|
|
Este servidor todavía no envía correo, así que la invitación no se
|
|
enviará sola: al terminar te mostraremos el enlace para que se lo pases.
|
|
</p>
|
|
{% endif %}
|
|
|
|
{% if can_make_admin %}
|
|
<label for="role">Rol</label>
|
|
<select id="role" name="role">
|
|
<option value="user">Usuario</option>
|
|
<option value="admin">Administrador</option>
|
|
</select>
|
|
{% else %}
|
|
<input type="hidden" name="role" value="user">
|
|
<p class="muted small">Los administradores sólo pueden dar de alta usuarios.</p>
|
|
{% endif %}
|
|
|
|
<div class="actions">
|
|
<button class="btn" type="submit">Dar de alta</button>
|
|
<a class="linkish" href="{{ url_for('members.index') }}">Cancelar</a>
|
|
</div>
|
|
</form>
|
|
{% endblock %}
|