Commit 34a03d90 authored by Roger Rüttimann's avatar Roger Rüttimann Committed by Roger Meier

require update_two_factor_requirement on all sub-entities users

parent 2a1c2c67
...@@ -423,7 +423,7 @@ class Group < Namespace ...@@ -423,7 +423,7 @@ class Group < Namespace
def update_two_factor_requirement def update_two_factor_requirement
return unless saved_change_to_require_two_factor_authentication? || saved_change_to_two_factor_grace_period? return unless saved_change_to_require_two_factor_authentication? || saved_change_to_two_factor_grace_period?
users.find_each(&:update_two_factor_requirement) User.from_union([users_with_descendants, project_users_with_descendants]).find_each(&:update_two_factor_requirement)
end end
def path_changed_hook def path_changed_hook
......
...@@ -728,7 +728,8 @@ class User < ApplicationRecord ...@@ -728,7 +728,8 @@ class User < ApplicationRecord
end end
def expanded_groups_requiring_two_factor_authentication def expanded_groups_requiring_two_factor_authentication
all_expanded_groups.where(require_two_factor_authentication: true) Group.from_union([all_expanded_groups.where(require_two_factor_authentication: true),
authorized_groups.where(require_two_factor_authentication: true)])
end end
# rubocop: disable CodeReuse/ServiceClass # rubocop: disable CodeReuse/ServiceClass
......
...@@ -654,7 +654,16 @@ describe Group do ...@@ -654,7 +654,16 @@ describe Group do
it 'calls #update_two_factor_requirement on each child project member' do it 'calls #update_two_factor_requirement on each child project member' do
project = create(:project, group: group) project = create(:project, group: group)
project_user = create(:user) project_user = create(:user)
project.add_user(project_user, GroupMember::OWNER) project.add_developer(project_user)
expects_other_user_to_require_two_factors
end
it 'calls #update_two_factor_requirement on each subgroups child project member' do
subgroup = create(:group, :nested, parent: group)
project = create(:project, group: subgroup)
project_user = create(:user)
project.add_developer(project_user)
expects_other_user_to_require_two_factors expects_other_user_to_require_two_factors
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment