This commit is contained in:
parent
63cf0b9fee
commit
12c5d2677d
|
@ -3,6 +3,7 @@
|
|||
- auth logix synced with core
|
||||
- added httpx
|
||||
- aiohttp and requests removed
|
||||
- core adapter loads data from redis now
|
||||
|
||||
[0.3.1]
|
||||
- glitchtip connect
|
||||
|
|
|
@ -63,7 +63,7 @@ def login_required(f):
|
|||
user_id, user_roles = await check_auth(req)
|
||||
if user_id and isinstance(user_id, str):
|
||||
context["user_id"] = user_id.strip()
|
||||
author = get_author_by_user(user_id)
|
||||
author = await get_author_by_user(user_id)
|
||||
if author and "id" in author:
|
||||
context["author_id"] = author["id"]
|
||||
return await f(*args, **kwargs)
|
||||
|
@ -80,7 +80,7 @@ def auth_request(f):
|
|||
user_id, user_roles = await check_auth(req)
|
||||
if user_id and isinstance(user_id, str):
|
||||
user_id = user_id.strip()
|
||||
author = get_author_by_user(user_id)
|
||||
author = await get_author_by_user(user_id)
|
||||
if author and "id" in author:
|
||||
req["author_id"] = author["id"]
|
||||
return await f(*args, **kwargs)
|
||||
|
|
|
@ -10,33 +10,33 @@ from services.rediscache import redis
|
|||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
def get_all_authors():
|
||||
async def get_all_authors():
|
||||
authors = []
|
||||
redis_key = "user:*"
|
||||
|
||||
result = redis.execute("GET", redis_key)
|
||||
result = await redis.execute("GET", redis_key)
|
||||
if isinstance(result, str):
|
||||
authors = json.loads(result)
|
||||
|
||||
return authors
|
||||
|
||||
|
||||
def get_author_by_user(user: str):
|
||||
async def get_author_by_user(user: str):
|
||||
author = None
|
||||
redis_key = f"user:{user}"
|
||||
|
||||
result = redis.execute("GET", redis_key)
|
||||
result = await redis.execute("GET", redis_key)
|
||||
if isinstance(result, str):
|
||||
author = json.loads(result)
|
||||
|
||||
return author
|
||||
|
||||
|
||||
def get_author_followed(author_id: int):
|
||||
async def get_author_followed(author_id: int):
|
||||
authors = []
|
||||
redis_key = f"author:{author_id}:follows-authors"
|
||||
|
||||
result = redis.execute("GET", redis_key)
|
||||
result = await redis.execute("GET", redis_key)
|
||||
if isinstance(result, str):
|
||||
authors = json.loads(result)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user