Skip to content

Commit

Permalink
Backward compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed Aug 21, 2024
1 parent 2ba429c commit 5ccff1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/doorkeeper/orm/active_record/mixins/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Application
class_name: Doorkeeper.config.access_token_class.to_s

validates :name, :uid, presence: true
validates :secret, presence: true, if: ->(application) { application.confidential? }
validates :secret, presence: true, if: -> { secret_required? }
validates :uid, uniqueness: { case_sensitive: true }
validates :confidential, inclusion: { in: [true, false] }

Expand Down Expand Up @@ -120,7 +120,7 @@ def generate_uid
end

def generate_secret
return if !confidential? || secret.present?
return if secret.present? || !secret_required?

renew_secret
end
Expand All @@ -138,6 +138,11 @@ def enforce_scopes?
Doorkeeper.config.enforce_configured_scopes?
end

def secret_required?
confidential? ||
!self.class.columns.detect { |column| column.name == "secret" }&.null
end

# Helper method to extract collection of serializable attribute names
# considering serialization options (like `only`, `except` and so on).
#
Expand Down

0 comments on commit 5ccff1d

Please sign in to comment.