Method: Devise::Models::DatabaseAuthenticatable#destroy_with_password

Defined in:
lib/devise/models/database_authenticatable.rb

#destroy_with_password(current_password) ⇒ Object

Destroy record when :current_password matches, otherwise returns error on :current_password. It also automatically rejects :current_password if it is blank.


105
106
107
108
109
110
111
112
113
114
115
# File 'lib/devise/models/database_authenticatable.rb', line 105

def destroy_with_password(current_password)
  result = if valid_password?(current_password)
    destroy
  else
    self.valid?
    self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
    false
  end

  result
end