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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix a bug in Device model that never allowed updating the default device
Klaus Zanders11315017da31
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.rbindex b18065afef9..9618588635c 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@@ -25,6 +25,14 @@ module TwoFactorAuthenticationself.class.has_default? userend+ def has_other_default?+ if persisted?+ Device.where.not(id:).exists?(active: true, default: true, user:)+ else+ has_default?+ end+ end+### Make the device active, and set it as default if no other device existsdef confirm_registration_and_save@@ -101,7 +109,7 @@ module TwoFactorAuthenticationenddef cannot_set_default_if_exists- if default && has_default?+ if default && has_other_default?errors.add :default, :default_already_existsend