Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uffd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca (strifel)
uffd
Commits
f9fb9075
Verified
Commit
f9fb9075
authored
4 years ago
by
nd
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: save user if we edit its roles resulting in changed group membership
parent
a4e123b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
uffd/role/utils.py
+7
-0
7 additions, 0 deletions
uffd/role/utils.py
uffd/role/views.py
+2
-4
2 additions, 4 deletions
uffd/role/views.py
uffd/user/views_user.py
+4
-4
4 additions, 4 deletions
uffd/user/views_user.py
with
13 additions
and
8 deletions
uffd/role/utils.py
0 → 100644
+
7
−
0
View file @
f9fb9075
from
uffd.role.models
import
Role
def
recalculate_user_groups
(
user
):
usergroups
=
set
()
for
role
in
Role
.
get_for_user
(
user
).
all
():
usergroups
.
update
(
role
.
group_dns
())
user
.
replace_group_dns
(
usergroups
)
This diff is collapsed.
Click to expand it.
uffd/role/views.py
+
2
−
4
View file @
f9fb9075
...
...
@@ -3,6 +3,7 @@ from flask import Blueprint, render_template, request, url_for, redirect, flash,
from
uffd.navbar
import
register_navbar
from
uffd.csrf
import
csrf_protect
from
uffd.role.models
import
Role
from
uffd.role.utils
import
recalculate_user_groups
from
uffd.user.models
import
Group
from
uffd.session
import
get_current_user
,
login_required
,
is_valid_session
from
uffd.database
import
db
...
...
@@ -59,10 +60,7 @@ def update(roleid=False):
members
=
role
.
member_ldap
()
for
user
in
members
:
usergroups
=
set
()
for
role
in
Role
.
get_for_user
(
user
).
all
():
usergroups
.
update
(
role
.
group_dns
())
user
.
replace_group_dns
(
usergroups
)
recalculate_user_groups
(
user
)
if
not
user
.
to_ldap
():
flash
(
'
updating group membership for user {} failed
'
.
format
(
user
.
loginname
))
...
...
This diff is collapsed.
Click to expand it.
uffd/user/views_user.py
+
4
−
4
View file @
f9fb9075
...
...
@@ -9,6 +9,7 @@ from uffd.selfservice import send_passwordreset
from
uffd.ldap
import
get_conn
,
escape_filter_chars
from
uffd.session
import
login_required
,
is_valid_session
,
get_current_user
from
uffd.role.models
import
Role
from
uffd.role.utils
import
recalculate_user_groups
from
uffd.database
import
db
from
.models
import
User
...
...
@@ -92,10 +93,9 @@ def update(uid=False):
else
:
flash
(
'
User updated
'
)
usergroups
=
set
()
for
role
in
Role
.
get_for_user
(
user
).
all
():
usergroups
.
update
(
role
.
group_dns
())
user
.
replace_group_dns
(
usergroups
)
recalculate_user_groups
(
user
)
if
not
user
.
to_ldap
():
flash
(
'
updating group membership for user {} failed
'
.
format
(
user
.
loginname
))
session
.
commit
()
else
:
flash
(
'
Error updating user: {}
'
.
format
(
conn
.
result
[
'
message
'
]))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment