Repository navigation
Allow email (OTP) users to be promoted to admin - #690
Conversation
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>
There was a problem hiding this comment.
🔵 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
ErrNotPromotableand theProvider == "github"check fromAuth.PromoteAdmin, plus its 400 branch in the admin handler, so any provider can be promoted (idempotent). - Updated the
/admin/userstemplate 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Good catch on |
Implements the "allow it outright" option from #565.
Auth.PromoteAdminno longer checks the provider;ErrNotPromotableand its 400 branch in the handler are gone. This also means a demoted wizard password account can be promoted again./admin/usersshows [promote to admin] for every non-admin, not only GitHub users.Bootstrap is unchanged:
EnsureAdminand theadmin_login/admin_github_idpin 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