Skip to content

Commit

Permalink
1131 fix deprecation warning for dirty attributes for rails > 5 (lynn…
Browse files Browse the repository at this point in the history
…dylanhurley#1132)

1131 cleanups
  • Loading branch information
Marinlemaignan authored and zachfeldman committed Apr 4, 2018
1 parent 23ed467 commit 3b39c1a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/models/devise_token_auth/concerns/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,18 @@ def destroy_expired_tokens
end
end

def should_remove_tokens_after_password_reset?
if Rails::VERSION::MAJOR <= 5
encrypted_password_changed? &&
DeviseTokenAuth.remove_tokens_after_password_reset
else
saved_change_to_encrypted_password? &&
DeviseTokenAuth.remove_tokens_after_password_reset
end
end

def remove_tokens_after_password_reset
return unless encrypted_password_changed? &&
DeviseTokenAuth.remove_tokens_after_password_reset
return unless should_remove_tokens_after_password_reset?

if tokens.present? && tokens.many?
client_id, token_data = tokens.max_by { |cid, v| v[:expiry] || v["expiry"] }
Expand Down

0 comments on commit 3b39c1a

Please sign in to comment.