@@ -131,6 +131,14 @@ def encrypt(*tokens)
131
131
@sorcery_config . encryption_provider . encrypt ( *tokens )
132
132
end
133
133
134
+ # FIXME: This method of passing config to the hashing provider is
135
+ # questionable, and has been refactored in Sorcery v1.
136
+ def set_encryption_attributes
137
+ @sorcery_config . encryption_provider . stretches = @sorcery_config . stretches if @sorcery_config . encryption_provider . respond_to? ( :stretches ) && @sorcery_config . stretches
138
+ @sorcery_config . encryption_provider . join_token = @sorcery_config . salt_join_token if @sorcery_config . encryption_provider . respond_to? ( :join_token ) && @sorcery_config . salt_join_token
139
+ @sorcery_config . encryption_provider . pepper = @sorcery_config . pepper if @sorcery_config . encryption_provider . respond_to? ( :pepper ) && @sorcery_config . pepper
140
+ end
141
+
134
142
protected
135
143
136
144
def authentication_response ( options = { } )
@@ -139,12 +147,6 @@ def authentication_response(options = {})
139
147
options [ :return_value ]
140
148
end
141
149
142
- def set_encryption_attributes
143
- @sorcery_config . encryption_provider . stretches = @sorcery_config . stretches if @sorcery_config . encryption_provider . respond_to? ( :stretches ) && @sorcery_config . stretches
144
- @sorcery_config . encryption_provider . join_token = @sorcery_config . salt_join_token if @sorcery_config . encryption_provider . respond_to? ( :join_token ) && @sorcery_config . salt_join_token
145
- @sorcery_config . encryption_provider . pepper = @sorcery_config . pepper if @sorcery_config . encryption_provider . respond_to? ( :pepper ) && @sorcery_config . pepper
146
- end
147
-
148
150
def add_config_inheritance
149
151
class_eval do
150
152
def self . inherited ( subclass )
@@ -177,6 +179,9 @@ def valid_password?(pass)
177
179
crypted = send ( sorcery_config . crypted_password_attribute_name )
178
180
return crypted == pass if sorcery_config . encryption_provider . nil?
179
181
182
+ # Ensure encryption provider is using configured values
183
+ self . class . set_encryption_attributes
184
+
180
185
salt = send ( sorcery_config . salt_attribute_name ) unless sorcery_config . salt_attribute_name . nil?
181
186
182
187
sorcery_config . encryption_provider . matches? ( crypted , pass , salt )
0 commit comments