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.



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/devise/models/database_authenticatable.rb', line 132

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