Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Reload otp_devices to get default

Oliver Günther797bc9f08e99
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb b/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
index 2c2e56290fa..862b3e0da7d 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
@@ -66,7 +66,7 @@ module TwoFactorAuthentication
Device.transaction do
Device.where(user_id: user_id).update_all(default: false)
update_column(:default, true)
- return true
+ true
end
end
diff --git a/modules/two_factor_authentication/spec/models/devices/default_device_spec.rb b/modules/two_factor_authentication/spec/models/devices/default_device_spec.rb
index 0433c4e57d4..fc1ea590924 100644
--- a/modules/two_factor_authentication/spec/models/devices/default_device_spec.rb
+++ b/modules/two_factor_authentication/spec/models/devices/default_device_spec.rb
@@ -28,7 +28,7 @@ describe 'Default device', with_2fa_ee: true, type: :model do
expect(user.otp_devices.get_default).to eq(other_otp)
subject.make_default!
- expect(user.otp_devices.get_default).to eq(subject)
+ expect(user.otp_devices.reload.get_default).to eq(subject)
end
end
end