4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/devise_password_expirable/models/database_authenticatable_patch.rb', line 4
def update_with_password(params={})
current_password = params.delete(:current_password)
new_password = params[:password]
new_password_confirmation = params[:password_confirmation]
result = if valid_password?(current_password) && new_password.present? && new_password_confirmation.present?
update_attributes(params)
else
if current_password.blank?
self.errors.add(:current_password, :blank)
elsif !valid_password?(current_password)
self.errors.add(:current_password, :invalid)
end
if new_password.blank?
self.errors.add(:password, :blank)
end
if new_password_confirmation.blank?
self.errors.add(:password_confirmation, :blank)
end
self.attributes = params
false
end
clean_up_passwords
result
end
|