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.



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/devise/models/database_authenticatable.rb', line 150

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

  result
end