From 3b39c1aa632156e4f1f8fa8f17e01a319023b673 Mon Sep 17 00:00:00 2001 From: hatenine Date: Wed, 4 Apr 2018 17:52:15 +0200 Subject: [PATCH] 1131 fix deprecation warning for dirty attributes for rails > 5 (#1132) 1131 cleanups --- app/models/devise_token_auth/concerns/user.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index 214374dc0..bb009ea81 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -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"] }