Fix tootctl accounts create failing because of date-of-birth check (#34663)

This commit is contained in:
Claire 2025-05-12 11:28:12 +02:00 committed by GitHub
parent 3357ae9889
commit 4e2aa78a56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 7 deletions

View file

@ -112,7 +112,7 @@ class User < ApplicationRecord
validates_with RegistrationFormTimeValidator, on: :create
validates :website, absence: true, on: :create
validates :confirm_password, absence: true, on: :create
validates :date_of_birth, presence: true, date_of_birth: true, on: :create, if: -> { Setting.min_age.present? }
validates :date_of_birth, presence: true, date_of_birth: true, on: :create, if: -> { Setting.min_age.present? && !bypass_registration_checks? }
validate :validate_role_elevation
scope :account_not_suspended, -> { joins(:account).merge(Account.without_suspended) }
@ -144,7 +144,7 @@ class User < ApplicationRecord
delegate :can?, to: :role
attr_reader :invite_code, :date_of_birth
attr_writer :external, :bypass_invite_request_check, :current_account
attr_writer :external, :bypass_registration_checks, :current_account
def self.those_who_can(*any_of_privileges)
matching_role_ids = UserRole.that_can(*any_of_privileges).map(&:id)
@ -501,8 +501,8 @@ class User < ApplicationRecord
!!@external
end
def bypass_invite_request_check?
@bypass_invite_request_check
def bypass_registration_checks?
@bypass_registration_checks
end
def sanitize_role
@ -549,7 +549,7 @@ class User < ApplicationRecord
end
def invite_text_required?
Setting.require_invite_text && !open_registrations? && !invited? && !external? && !bypass_invite_request_check?
Setting.require_invite_text && !open_registrations? && !invited? && !external? && !bypass_registration_checks?
end
def trigger_webhooks