File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,9 +118,10 @@ class << self
118118 attr_reader :orm_adapter
119119
120120 def configure ( &block )
121- @config = Config ::Builder . new ( &block ) . build
121+ builder = Config ::Builder . new ( &block )
122+ @config = builder . config
122123 setup
123- @config
124+ builder . build
124125 end
125126
126127 # @return [Doorkeeper::Config] configuration instance
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ def validate!
1111 validate_reuse_access_token_value
1212 validate_token_reuse_limit
1313 validate_secret_strategies
14+ validate_custom_access_token_attributes
1415 end
1516
1617 private
@@ -48,6 +49,27 @@ def validate_token_reuse_limit
4849 )
4950 @token_reuse_limit = 100
5051 end
52+
53+ # Validate that the access_token and access_grant models
54+ # both respond to all of the custom attributes
55+ def validate_custom_access_token_attributes
56+ return if custom_access_token_attributes . blank?
57+
58+ unrecognized_attributes = [ ]
59+ custom_access_token_attributes . each do |attrib |
60+ [ access_token_model , access_grant_model ] . each do |model |
61+ next if model . has_attribute? ( attrib )
62+
63+ unrecognized_attributes << attrib
64+ ::Rails . logger . warn (
65+ "[DOORKEEPER] #{ access_token_model } does not respond to custom attribute '#{ attrib } '. " \
66+ "This custom attribute will be ignored." ,
67+ )
68+ end
69+ end
70+
71+ @custom_access_token_attributes -= unrecognized_attributes
72+ end
5173 end
5274 end
5375end
You can’t perform that action at this time.
0 commit comments