Skip to content

feat(config): show credential setup form when enabling require_login#692

Merged
javi11 merged 3 commits into
mainfrom
session/flamboyant-bohr-09bc0b
Jun 17, 2026
Merged

feat(config): show credential setup form when enabling require_login#692
javi11 merged 3 commits into
mainfrom
session/flamboyant-bohr-09bc0b

Conversation

@javi11

@javi11 javi11 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • When the Require Login toggle is turned ON in the Auth Config section and no users exist in the database, a Set Up Admin Credentials form now appears inline — preventing admin lockout on first enable
  • Form collects username (min 3 chars), password (min 8 chars), and confirm password with client-side validation
  • On save, the component registers the user via POST /api/auth/register before saving the config — both steps happen atomically from the UI's perspective
  • When login is required and a user already exists, a green Credentials configured badge is shown instead (with a pointer to the user menu for password changes)
  • When login is disabled, the existing security warning continues to appear as before

What changed

frontend/src/components/config/AuthConfigSection.tsx — only file changed; no backend changes needed (existing /api/auth/register and /api/auth/registration-status endpoints cover the requirements.

  • Fetches registration status on mount via apiClient.checkRegistrationStatus()
  • New local state: registrationStatus, credentialForm, credentialError, isRegistering
  • handleSave now runs registration before config save when credentials are needed
  • Two new conditional UI blocks: credential form (no users) and status badge (users exist)

Test plan

  • Toggle Require Login → ON with no existing users → credential form appears
  • Submit without filling form → validation error shown, save blocked
  • Fill valid credentials and save → user registered, config saved, redirected to login
  • Log in with the new credentials successfully
  • With users already present, toggle Require Login → ON → "Credentials configured" badge shown, no form
  • Toggle Require Login → OFF → security warning shown, no credential form

@javi11 javi11 merged commit 87f8611 into main Jun 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant