Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1131 fix deprecation warning for dirty attributes for rails > 5 #1132

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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? &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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