Skip to content

Commit

Permalink
auditlog: skip notification for admin triggered account removal
Browse files Browse the repository at this point in the history
This leaks admin IP address to the user.

Fixes WeblateOrg#9983
  • Loading branch information
nijel committed Sep 19, 2023
1 parent 15059e5 commit 9a54380
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions weblate/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def should_notify(self):
and self.user.is_active
and self.user.email
and self.activity in NOTIFY_ACTIVITY
and not self.params.get("skip_notify")
)

def check_rate_limit(self, request):
Expand Down
4 changes: 2 additions & 2 deletions weblate/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
from weblate.trans.signals import user_pre_delete


def remove_user(user, request):
def remove_user(user, request, **params):
"""Remove user account."""
# Send signal (to commit any pending changes)
user_pre_delete.send(instance=user, sender=user.__class__)

# Store activity log and notify
AuditLog.objects.create(user, request, "removed")
AuditLog.objects.create(user, request, "removed", **params)

# Remove any email validation codes
invalidate_reset_codes(user)
Expand Down
2 changes: 1 addition & 1 deletion weblate/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def post(self, request, **kwargs):
user.groups.remove(form.cleaned_data["remove_group"])
return HttpResponseRedirect(self.get_success_url() + "#groups")
if "remove_user" in request.POST:
remove_user(user, request)
remove_user(user, request, skip_notify=True)
return HttpResponseRedirect(self.get_success_url() + "#groups")

return super().post(request, **kwargs)
Expand Down

0 comments on commit 9a54380

Please sign in to comment.