New accounts only from an administrator or an administrator's invitation

Anyone can add an aircraft and so manage its people, so invitations from
non-administrators could bring in new accounts without an administrator.

- An invitation makes a new account only if whoever made it is still an
  administrator when it's used; an aircraft's Access page invitations are
  for people who already have an account (its welcome page says so).
- Signing invitations no longer make accounts: the mechanic needs one
  first, and the owner is told when they don't have one.
- With SSO, "Continue with <provider>" on an administrator's invitation
  makes the account and accepts the invitation (only for its address when
  it has one), so invitations work without OIDC_AUTO_CREATE_USERS. That
  setting stays, documented as giving accounts without an invitation; the
  Authentik example now leaves it off.
- Docs: who makes accounts (guide, README, Authentik, .env.example, API).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-15 19:00:45 -05:00
1 parent b4c7aaa3ff
commit 19bc3efa19
19 files changed
+159 -85

No files matched your search

+22
View File
@@ -166,4 +166,26 @@ class InvitationsTest < ActionDispatch::IntegrationTest
assert_response :not_found
assert_not inv.reload.revoked?
end
test "only an administrator's invitation makes new accounts; an owner's is for existing accounts" do
owners = invitation(creator: @owner, grants: [ [ @a, "pilot" ] ])
get join_path(owners.token)
assert_select "form[action=?]", account_join_path(owners.token), 0
assert_includes response.body, "This invitation is for an existing account"
post account_join_path(owners.token), params: { email_address: "new@example.com", name: "X", password: PASSWORD, password_confirmation: PASSWORD }
assert_not User.exists?(email_address: "new@example.com")
assert_equal 0, owners.reload.uses_count
existing = create_user("existing@example.com")
sign_in existing
post accept_join_path(owners.token)
assert_equal "pilot", existing.role_for(@a).key
end
test "an administrator's invitation stops making accounts once its creator isn't an administrator" do
inv = invitation
@admin.update!(admin: false)
post account_join_path(inv.token), params: { email_address: "new@example.com", name: "X", password: PASSWORD, password_confirmation: PASSWORD }
assert_not User.exists?(email_address: "new@example.com")
end
end