From 2380e88168bb00e2bc2fb51fee376e584bae86a5 Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 19 Dec 2023 19:42:53 +0300 Subject: [PATCH] cached-request-8 --- services/auth.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/services/auth.py b/services/auth.py index 8510cf7..07437f2 100644 --- a/services/auth.py +++ b/services/auth.py @@ -60,13 +60,10 @@ def login_required(f): user_id = await check_auth(req) if user_id: context["user_id"] = user_id - if not cached_authors: - get_all_authors() - if cached_authors: - authors_by_user, authors_by_id = cached_authors - author = authors_by_user.get(user_id) - if author and "id" in author: - context["author_id"] = author["id"] + authors_by_user, authors_by_id = get_all_authors() if not cached_authors else cached_authors + author = authors_by_user.get(user_id) + if author and "id" in author: + context["author_id"] = author["id"] return await f(*args, **kwargs) return decorated_function