Skip to content

Setup wizard: offer email one-time-code login for the admin account #695

Open

Description

@compscidr

Background

#565 / #690 let an existing admin promote an email (OTP) user, but the setup wizard can't create one. Its admin step offers only:

  • email + password: CreatePasswordAdmin (auth/password.go) creates a password-provider user; nothing is sent to the email,
  • GitHub: createAdminUser (wizard/wizard.go) via EnsureAdmin.

The OTP path (auth/otp.go) only calls UpsertUser, so it never bootstraps an admin. A site that wants OTP-only login today has to create a password admin, sign in by OTP, promote that account, and then demote the password one.

Proposal

Add a third option to the wizard's admin step: sign in with an emailed code.

  • It is optional. The wizard keeps working with no mail server, and SMTP fields (smtp_host, smtp_from, etc.) appear only when this option is picked.
  • The wizard sends a code to the entered address, and the operator enters it to finish. This also proves the SMTP settings work before the install completes.
  • On success, create the email-provider user and its admin_users row in one transaction guarded by "no admin exists yet", like CreatePasswordAdmin (no ErrAdminExists race).
  • Keep the existing setup-code gate (SetupUnlocked) in front of it.
  • Persist the SMTP settings so login-page OTP is enabled afterwards.

Open questions

  • Where the SMTP settings are stored: written to .env like the other wizard config, or kept as DB settings.
  • Whether the README's "no mail server is needed" wording for the wizard should change to "needed only for the email-code option".

Follow-on from #565 / #690.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions