-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent workspace admins to modify the system user on a workspace #5664
Conversation
d111b9a
to
8bfb28c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5664 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 565 565
Lines 25836 26175 +339
==========================================
+ Hits 25836 26175 +339 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
temba/tests/base.py
Outdated
@@ -72,6 +72,10 @@ def setUp(self): | |||
self.agent = self.create_user("[email protected]", first_name="Agnes") | |||
self.customer_support = self.create_user("[email protected]", is_staff=True) | |||
|
|||
self.system_user = self.create_user("[email protected]") | |||
self.system_user.settings.is_system = True | |||
self.system_user.settings.save(update_fields=("is_system",)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just create this user in the tests that need it.. it's not a common case
temba/orgs/views/views.py
Outdated
.exclude(id=user.id) | ||
.exclude(settings__is_system=True) | ||
.exists() | ||
and not user.settings.is_system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think replace this line with .filter(settings__is_system=False)
on line 567
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am adjust that to actually allow staff to manage that on UI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think how this will work is that we create the user with an email we control and then invite them to workspaces as necessary. We don't need to update them or remove them (for now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, staff no longer allowed to post so that could not work
8bfb28c
to
68e38cd
Compare
68e38cd
to
efda4c1
Compare
super(BaseListView, self) | ||
.derive_queryset(**kwargs) | ||
.filter(id__in=self.request.org.get_users().values_list("id", flat=True)) | ||
.order_by(Lower("email")) | ||
.select_related("settings") | ||
) | ||
|
||
if not self.request.user.is_staff: | ||
qs = qs.exclude(settings__is_system=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to update admin_count
below on line 435
No description provided.