Skip to content

Allow email (OTP) users to be promoted to admin - #690

Merged
compscidr merged 2 commits into
mainfrom
compscidr/allow-email-otp-users-to-be-promoted-to-admin
Oct 17, 2026
Merged

compscidr merged 2 commits into
mainfrom
compscidr/allow-email-otp-users-to-be-promoted-to-admin

Conversation

@compscidr

Copy link
Copy Markdown
Collaborator

Implements the "allow it outright" option from #565.

  • Auth.PromoteAdmin no longer checks the provider; ErrNotPromotable and its 400 branch in the handler are gone. This also means a demoted wizard password account can be promoted again.
  • /admin/users shows [promote to admin] for every non-admin, not only GitHub users.
  • README: the Managing Admins and email-login sections now say email users can be promoted, and warn that an email admin is only as secure as that mailbox.
  • Tests: the email-refused cases are now email-allowed cases (auth unit test, API test, render test).

Bootstrap is unchanged: EnsureAdmin and the admin_login/admin_github_id pin still apply only to GitHub, so the first admin still comes from the wizard or a pinned GitHub login.

Closes #565

🤖 Generated with Claude Code

Drop the GitHub-only gate in Auth.PromoteAdmin and ErrNotPromotable,
show the promote control for every non-admin on /admin/users, and
update the README. An email login is as strong as its mailbox, which
is also what a GitHub account falls back on for recovery.

Closes #565

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 09:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It is a security-sensitive authorization change that broadens admin promotion to weaker email/OTP credentials, and the admin Users page help text (admin_users.html line 7) still states "Only GitHub users can be made admin," leaving a contradiction that a human should resolve.

No open issues 🎉

What changed in this PR

This PR implements the "allow it outright" direction from issue #565, letting email/OTP users (not just GitHub users) be promoted to admin via the /admin/users page. It removes the provider-based gate that previously restricted admin promotion to GitHub accounts, while keeping the bootstrap/pin logic (EnsureAdmin, admin_login/admin_github_id) GitHub-only. The change touches the auth layer, the admin handler, the admin UI template, documentation, and the corresponding tests.

Changes:

  • Removed ErrNotPromotable and the Provider == "github" check from Auth.PromoteAdmin, plus its 400 branch in the admin handler, so any provider can be promoted (idempotent).
  • Updated the /admin/users template to show [promote to admin] for every non-admin and updated README guidance on managing admins and email login.
  • Flipped the previously "email-refused" tests into "email-allowed" tests (auth unit test, promote API test, render test).
File Description
auth/​auth.go Removes ErrNotPromotable var and the provider check in PromoteAdmin; updates the doc comment to reflect any-provider promotion.
admin/​admin.go Drops the ErrNotPromotable → 400 case in the PromoteAdmin handler.
themes/​default/​templates/​admin_users.html Changes the {{ else if eq .Provider "github" }} gate to {{ else }} so all non-admins get a promote control.
README.md Updates Managing Admins and Email Login sections to say email users can be promoted, with a mailbox-trust caveat.
auth/​auth_test.go Renames ..._Refused to ..._AddsRow and asserts the email user becomes an admin.
admin/​admin_test.go Updates render and API tests to expect a promote control / 200 for email users.

Review effort: Balanced

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@compscidr

Copy link
Copy Markdown
Collaborator Author

Good catch on admin_users.html line 7. It now reads "An email-login admin is only as secure as that mailbox. The last admin can't be demoted." Fixed in the latest commit. Allowing email admins is the direction chosen in #565.

@compscidr
compscidr merged commit 77d5316 into main Oct 17, 2026
5 checks passed
@compscidr
compscidr deleted the compscidr/allow-email-otp-users-to-be-promoted-to-admin branch October 17, 2026 09:46
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.

Allow email (OTP) users to be promoted to admin

2 participants