Skip to content

Commit 4a103ed

Browse files
Validate that token is valid for patch request last token (lynndylanhurley#1386)
1 parent 4d2d702 commit 4a103ed

File tree

1 file changed

+3
-3
lines changed
  • app/models/devise_token_auth/concerns

1 file changed

+3
-3
lines changed

app/models/devise_token_auth/concerns/user.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,17 @@ def token_is_current?(token, client)
137137
def token_can_be_reused?(token, client)
138138
# ghetto HashWithIndifferentAccess
139139
updated_at = tokens[client]['updated_at'] || tokens[client][:updated_at]
140-
last_token = tokens[client]['last_token'] || tokens[client][:last_token]
140+
last_token_hash = tokens[client]['last_token'] || tokens[client][:last_token]
141141

142142
return true if (
143143
# ensure that the last token and its creation time exist
144-
updated_at && last_token &&
144+
updated_at && last_token_hash &&
145145

146146
# ensure that previous token falls within the batch buffer throttle time of the last request
147147
updated_at.to_time > Time.zone.now - DeviseTokenAuth.batch_request_buffer_throttle &&
148148

149149
# ensure that the token is valid
150-
DeviseTokenAuth::TokenFactory.valid_token_hash?(last_token)
150+
DeviseTokenAuth::TokenFactory.token_hash_is_token?(last_token_hash, token)
151151
)
152152
end
153153

0 commit comments

Comments
 (0)