mirror of
https://github.com/SMNETSTUDIO/WeChat-AI.git
synced 2026-11-29 10:27:00 +08:00
Both halves of #7 were the frontend disagreeing with auth logic the backend already had. /app forced a non-empty invite code before it would POST /api/v1/auth/register, so a fresh local-only deployment could never register anyone: the backend waives the invite for the first user when no admin is configured, but nobody exists yet who could issue a code. /api/v1/auth/config now publishes that waiver as `bootstrapAvailable`, and the register form only requires a code when the backend actually wants one — marking the field optional and explaining that the first account becomes the admin. The same field also fixes an invite being demanded under INVITE_REQUIRED_FOR_LOCAL=false. The predicate is extracted to canBootstrapFirstAdmin() and used by both the config and register endpoints, since the two computing it separately is how they drifted apart in the first place. /admin bounced every 401 to /api/v1/auth/login, which answers 503 under LINUXDO_AUTH_ENABLED=false — a dead end on a page that already has a password form. It now stays put and shows that form whenever local auth is enabled, keeping the OAuth redirect for OAuth-only setups, and shapes the gate (buttons and subtitle) to the methods actually available. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>