Skip to content

Commit

Permalink
Warning instead of raising config errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyC-za committed Mar 24, 2023
1 parent 34573fb commit a4d4767
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/doorkeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ class << self
attr_reader :orm_adapter

def configure(&block)
@config = Config::Builder.new(&block).build
builder = Config::Builder.new(&block)
@config = builder.config
setup
@config
builder.build
end

# @return [Doorkeeper::Config] configuration instance
Expand Down
22 changes: 22 additions & 0 deletions lib/doorkeeper/config/validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def validate!
validate_reuse_access_token_value
validate_token_reuse_limit
validate_secret_strategies
validate_custom_access_token_attributes
end

private
Expand Down Expand Up @@ -48,6 +49,27 @@ def validate_token_reuse_limit
)
@token_reuse_limit = 100
end

# Validate that the access_token and access_grant models
# both respond to all of the custom attributes
def validate_custom_access_token_attributes
return if custom_access_token_attributes.blank?

unrecognized_attributes = []
custom_access_token_attributes.each do |attrib|
[access_token_model, access_grant_model].each do |model|
next if model.has_attribute?(attrib)

unrecognized_attributes << attrib
::Rails.logger.warn(
"[DOORKEEPER] #{access_token_model} does not respond to custom attribute '#{attrib}'. " \
"This custom attribute will be ignored.",
)
end
end

@custom_access_token_attributes -= unrecognized_attributes
end
end
end
end

0 comments on commit a4d4767

Please sign in to comment.