Add and apply Style/RedundantSelf rubocop rule

This commit is contained in:
Javi Martín
2021-08-11 15:20:30 +02:00
parent a93384a2e1
commit adba81ea89
9 changed files with 20 additions and 17 deletions

View File

@@ -42,11 +42,11 @@ module Devise
module Models
module PasswordExpirable
def need_change_password?
self.administrator? && password_expired?
administrator? && password_expired?
end
def password_expired?
self.password_changed_at < self.expire_password_after.ago
password_changed_at < expire_password_after.ago
end
end
@@ -60,11 +60,11 @@ module Devise
end
def current_equal_password_validation
if !self.new_record? && !self.encrypted_password_change.nil? && !self.erased?
if !new_record? && !encrypted_password_change.nil? && !erased?
dummy = self.class.new
dummy.encrypted_password = self.encrypted_password_change.first
dummy.password_salt = self.password_salt_change.first if self.respond_to?(:password_salt_change) && !self.password_salt_change.nil?
self.errors.add(:password, :equal_to_current_password) if dummy.valid_password?(self.password)
dummy.encrypted_password = encrypted_password_change.first
dummy.password_salt = password_salt_change.first if respond_to?(:password_salt_change) && !password_salt_change.nil?
errors.add(:password, :equal_to_current_password) if dummy.valid_password?(password)
end
end
end