From c8c401e2c587f94076ac8713eee03f6d9744409f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 15 Feb 2023 10:49:13 +0100 Subject: [PATCH] lib: don't try to cache generated avatar with full user, only cache with name closes #4690 Signed-off-by: Jens Langhammer --- authentik/lib/avatars.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/authentik/lib/avatars.py b/authentik/lib/avatars.py index 634cf6485..fb0afe346 100644 --- a/authentik/lib/avatars.py +++ b/authentik/lib/avatars.py @@ -86,7 +86,7 @@ def generate_colors(text: str) -> tuple[str, str]: @cache # pylint: disable=too-many-arguments,too-many-locals def generate_avatar_from_name( - user: "User", + name: str, length: int = 2, size: int = 64, rounded: bool = False, @@ -98,8 +98,6 @@ def generate_avatar_from_name( Inspired from: https://github.com/LasseRafn/ui-avatars """ - name = user.name if user.name != "" else "a k" - name_parts = name.split() # Only abbreviate first and last name if len(name_parts) > 2: @@ -152,7 +150,7 @@ def generate_avatar_from_name( def avatar_mode_generated(user: "User", mode: str) -> Optional[str]: """Wrapper that converts generated avatar to base64 svg""" - svg = generate_avatar_from_name(user) + svg = generate_avatar_from_name(user.name if user.name != "" else "a k") return f"data:image/svg+xml;base64,{b64encode(svg.encode('utf-8')).decode('utf-8')}"