Module: Devise::Models::ResourceAuthenticatable

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

Instance Method Summary collapse

Instance Method Details

#update_with_password(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/devise/models/resource_authenticatable.rb', line 4

def update_with_password(params)
  current_password = params.delete(:current_password)

  if params[:password].blank?
    params.delete(:password)
    params.delete(:password_confirmation) if params[:password_confirmation].blank?
  end

  result = if valid_password?(current_password)
             update_attributes(params)
           else
             assign_attributes(params)
             valid?
             errors.add(:current_password, current_password.blank? ? :blank : :invalid)
             false
           end

  clean_up_passwords
  result
end

#update_without_password(params) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/devise/models/resource_authenticatable.rb', line 25

def update_without_password(params)
  params.delete(:password)
  params.delete(:password_confirmation)

  result = update_attributes(params)
  clean_up_passwords
  result
end