Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
34a03d90
Commit
34a03d90
authored
Feb 06, 2019
by
Roger Rüttimann
Committed by
Roger Meier
Jun 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
require update_two_factor_requirement on all sub-entities users
parent
2a1c2c67
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
app/models/group.rb
app/models/group.rb
+1
-1
app/models/user.rb
app/models/user.rb
+2
-1
spec/models/group_spec.rb
spec/models/group_spec.rb
+10
-1
No files found.
app/models/group.rb
View file @
34a03d90
...
@@ -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
...
...
app/models/user.rb
View file @
34a03d90
...
@@ -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
...
...
spec/models/group_spec.rb
View file @
34a03d90
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment