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

+12 -4
View File
@@ -7,9 +7,10 @@
# users edit their email. Otherwise, sign in with a password once and link
# from the profile page.
#
# Someone without an account gets one only from an administrator's
# invitation they opened first (AccessInvitation, accepted at once), or for
# anyone the provider lets in when OIDC_AUTO_CREATE_USERS is on.
# Someone without an account gets one only from an invitation they opened
# first that can make one (an administrator's AccessInvitation, accepted at
# once; an Owner's SigningInvitation, for its address), or for anyone the
# provider lets in when OIDC_AUTO_CREATE_USERS is on.
class SsoController < ApplicationController
allow_unauthenticated_access only: %i[callback failure]
before_action :require_sso
@@ -89,7 +90,7 @@ class SsoController < ApplicationController
email = auth.info&.email.to_s.strip.downcase
return if email.blank? || User.exists?(email_address: email)
invitation = invitation_making_account(email)
return unless invitation || Sso.auto_create_users?
return unless invitation || signing_invitation_making_account?(email) || Sso.auto_create_users?
User.transaction do
# The random password is never shown; a password reset can set a real one.
user = User.create!(email_address: email, name: auth.info&.name.presence, sso_uid: auth.uid, password: SecureRandom.base58(40))
@@ -100,6 +101,13 @@ class SsoController < ApplicationController
nil
end
# A signing invitation opened in this browser before signing in, from an
# Owner, for this email address.
def signing_invitation_making_account?(email)
invitation = SigningInvitation.find_usable(session[:signing_token])
invitation.present? && invitation.creates_account? && invitation.email == email
end
# The invitation opened in this browser before signing in, when it can
# make an account (an administrator's) for this email address.
def invitation_making_account(email)