Owners can invite mechanics again; who adds aircraft is an admin setting

- Admin → Settings → Who can add aircraft: administrators only (the
  default) or everyone. Adding an aircraft or importing a .sam.zip makes
  you its Owner, so this decides who can become one.
- A signing invitation from an Owner of the aircraft (or an
  administrator) lets the outside mechanic create an account for the
  invited address again, with a password or by signing in with SSO;
  checked when it's used. Others' signing invitations still need an
  existing account, and say so.
- Docs: who makes accounts, the new setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-15 19:09:49 -05:00
1 parent 19bc3efa19
commit 9a20c91f5e
30 files changed
+219 -40

No files matched your search

+21 -11
View File
@@ -159,7 +159,6 @@ class ElectronicSignaturesTest < ActionDispatch::IntegrationTest
post aircraft_logbook_entry_signing_invitations_path(@a, @entry), params: { signing_invitation: { email: "Outside@Example.com", message: "Thanks!" } }
end
end
assert_match "They don't have an account here yet", flash[:notice]
mail = ActionMailer::Base.deliveries.last
assert_equal [ "outside@example.com" ], mail.to
path = mail.text_part.body.to_s[%r{http://example\.com(/sign/[\w-]+)}, 1]
@@ -167,16 +166,8 @@ class ElectronicSignaturesTest < ActionDispatch::IntegrationTest
get path
assert_includes response.body, "sign in as <strong>outside@example.com</strong>"
assert_includes response.body, "no account for outside@example.com yet" # a signing link doesn't make accounts
post "#{path}/account", params: { name: "Olive Outside", password: "longpassword1", password_confirmation: "longpassword1" }
assert_response :not_found
assert_not User.exists?(email_address: "outside@example.com")
# The administrator adds their account; they sign in and come back to the link.
User.create!(email_address: "outside@example.com", name: "Olive Outside", password: "longpassword1")
get path
post session_path, params: { email_address: "outside@example.com", password: "longpassword1" }
assert_redirected_to "http://www.example.com#{path}"
post "#{path}/account", params: { name: "Olive Outside", password: "longpassword1", password_confirmation: "longpassword1" } # an Owner's invitation
assert_redirected_to path
follow_redirect!
assert_select "form[action='#{certificates_path(return_to: path)}']" # add a certificate first
post certificates_path(return_to: path), params: { user_certificate: { kind: "IA", number: "2222222" } }
@@ -223,4 +214,23 @@ class ElectronicSignaturesTest < ActionDispatch::IntegrationTest
patch enable_admin_user_path(@mech)
refute @mech.reload.disabled?
end
test "a signing invitation from someone who isn't an Owner doesn't make accounts" do
mechanic = create_user("shop@example.com")
@a.roles.create!(user: mechanic, role: "mechanic")
sign_in mechanic
perform_enqueued_jobs do
post aircraft_logbook_entry_signing_invitations_path(@a, @entry), params: { signing_invitation: { email: "outside2@example.com" } }
end
assert_match "They don't have an account here yet", flash[:notice]
path = ActionMailer::Base.deliveries.last.text_part.body.to_s[%r{http://example\.com(/sign/[\w-]+)}, 1]
assert_match "if you don't have one, ask the owner", ActionMailer::Base.deliveries.last.text_part.body.to_s
delete session_path
get path
assert_includes response.body, "no account for outside2@example.com yet"
assert_select "form[action$='/account']", 0
post "#{path}/account", params: { name: "X", password: "longpassword1", password_confirmation: "longpassword1" }
assert_not User.exists?(email_address: "outside2@example.com")
end
end