From 1cff8902dd03e342457f8641d5a5a9d7d3d99572 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Thu, 11 Jan 2024 15:25:15 +0100 Subject: [PATCH] fix clone with nodata Signed-off-by: Marc 'risson' Schmitt --- authentik/events/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/authentik/events/utils.py b/authentik/events/utils.py index cf1b1b78b..418375857 100644 --- a/authentik/events/utils.py +++ b/authentik/events/utils.py @@ -72,10 +72,13 @@ def model_to_dict(model: Model) -> dict[str, Any]: } -def get_user(user: User, original_user: Optional[User] = None) -> dict[str, Any]: +def get_user(user: User | AnonymousUser, original_user: Optional[User] = None) -> dict[str, Any]: """Convert user object to dictionary, optionally including the original user""" if isinstance(user, AnonymousUser): - user = get_anonymous_user() + try: + user = get_anonymous_user() + except User.DoesNotExist: + return {} user_data = { "username": user.username, "pk": user.pk,