diff --git a/src/pretix/control/logdisplay.py b/src/pretix/control/logdisplay.py index 46ab30cc1d..2a5c7a92ea 100644 --- a/src/pretix/control/logdisplay.py +++ b/src/pretix/control/logdisplay.py @@ -288,3 +288,9 @@ def pretixcontrol_logentry_display(sender: Event, logentry: LogEntry, **kwargs): elif data.get('is_active') is False: text = text + ' ' + str(_('Your account has been disabled.')) return text + + if logentry.action_type == 'pretix.control.auth.user.impersonated': + return str(_('You impersonated {}.')).format(data['other_email']) + + if logentry.action_type == 'pretix.control.auth.user.impersonate_stopped': + return str(_('You stopped impersonating {}.')).format(data['other_email']) diff --git a/src/pretix/control/views/users.py b/src/pretix/control/views/users.py index 85df389b2f..6c558690f3 100644 --- a/src/pretix/control/views/users.py +++ b/src/pretix/control/views/users.py @@ -106,6 +106,12 @@ class UserImpersonateView(AdministratorPermissionRequiredMixin, RecentAuthentica def post(self, request, *args, **kwargs): self.object = get_object_or_404(User, pk=self.kwargs.get("id")) + self.request.user.log_action('pretix.control.auth.user.impersonated', + user=request.user, + data={ + 'other': self.kwargs.get("id"), + 'other_email': self.object.email + }) login_user(request, self.object) return redirect(reverse('control:index')) @@ -113,7 +119,14 @@ class UserImpersonateView(AdministratorPermissionRequiredMixin, RecentAuthentica class UserImpersonateStopView(LoginRequiredMixin, View): def post(self, request, *args, **kwargs): + impersonated = request.user release_hijack(request) + request.user.log_action('pretix.control.auth.user.impersonate_stopped', + user=request.user, + data={ + 'other': impersonated.pk, + 'other_email': impersonated.email + }) return redirect(reverse('control:index'))