-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#4245] Allowing password to nil #4261
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,17 +37,18 @@ def self.required_fields(klass) | |
# the hashed password. | ||
def password=(new_password) | ||
@password = new_password | ||
self.encrypted_password = password_digest(@password) if @password.present? | ||
self.encrypted_password = password_digest(@password) | ||
end | ||
|
||
# Verifies whether a password (ie from sign in) is the user password. | ||
def valid_password?(password) | ||
return false if password.blank? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we can remove this condition since it's already present inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but since we're returning |
||
Devise::Encryptor.compare(self.class, encrypted_password, password) | ||
end | ||
|
||
# Set password and password confirmation to nil | ||
def clean_up_passwords | ||
self.password = self.password_confirmation = nil | ||
@password = @password_confirmation = nil | ||
end | ||
|
||
# Update record attributes when :current_password matches, otherwise | ||
|
@@ -144,6 +145,7 @@ def send_password_change_notification | |
# See https://github.com/plataformatec/devise-encryptable for examples | ||
# of other hashing engines. | ||
def password_digest(password) | ||
return if password.blank? | ||
Devise::Encryptor.digest(self.class, password) | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucasmazza Most of the test cases has been failed because of I have removed
@password.present?
condition. I couldn't find the reason that why it is failing. Could you help me?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the looks of it we need to update
clean_up_passwords
to clear the instance variables directly, instead of callingpassword=
.