Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions app/models/concerns/user_access_key_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ def valid_password?(password)
def password=(new_password)
@password = new_password
return if @password.blank?
digest = Encryption::PasswordVerifier.digest(@password)
self.encrypted_password_digest = digest.to_s
# Until we drop the old columns, still write to them so that we can rollback
write_legacy_password_attributes(digest)
self.encrypted_password_digest = Encryption::PasswordVerifier.digest(@password).to_s
end

# This is a devise method, which we are overriding. This should not be removed
Expand All @@ -35,13 +32,6 @@ def authenticatable_salt

private

def write_legacy_password_attributes(digest)
self.encrypted_password = digest.encrypted_password
self.encryption_key = digest.encryption_key
self.password_salt = digest.password_salt
self.password_cost = digest.password_cost
end

def log_password_verification_failure
metadata = {
event: 'Failure to validate password',
Expand Down
15 changes: 0 additions & 15 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,19 +417,4 @@
expect(user.authenticatable_salt).to eq(salt)
end
end

context 'when a password is updated' do
it 'writes encrypted_password_digest and the legacy password attributes' do
user = create(:user)

expected = {
encrypted_password: user.encrypted_password,
encryption_key: user.encryption_key,
password_salt: user.password_salt,
password_cost: user.password_cost,
}.to_json

expect(user.encrypted_password_digest).to eq(expected)
end
end
end