This commit is contained in:
parent
8830908307
commit
8e8952dd46
|
@ -95,10 +95,6 @@ async def get_my_followed(_, info):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
author = session.query(Author).filter(Author.user == user_id).first()
|
author = session.query(Author).filter(Author.user == user_id).first()
|
||||||
if author:
|
if author:
|
||||||
# update author's last_seen timestamp
|
|
||||||
author.last_seen = time.time()
|
|
||||||
session.add(author)
|
|
||||||
|
|
||||||
authors_query = (
|
authors_query = (
|
||||||
select(Author)
|
select(Author)
|
||||||
.join(AuthorFollower, AuthorFollower.follower == Author.id)
|
.join(AuthorFollower, AuthorFollower.follower == Author.id)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
import aiohttp
|
from aiohttp import ClientSession
|
||||||
from aiohttp.web import HTTPUnauthorized
|
from starlette.exceptions import HTTPException
|
||||||
|
|
||||||
from settings import AUTH_URL
|
from settings import AUTH_URL
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ async def check_auth(req) -> str | None:
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
# Asynchronous HTTP request to the authentication server
|
# Asynchronous HTTP request to the authentication server
|
||||||
async with aiohttp.ClientSession() as session:
|
async with ClientSession() as session:
|
||||||
async with session.post(AUTH_URL, json=gql, headers=headers) as response:
|
async with session.post(AUTH_URL, json=gql, headers=headers) as response:
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
data = await response.json()
|
data = await response.json()
|
||||||
|
@ -47,7 +47,7 @@ async def check_auth(req) -> str | None:
|
||||||
print(f"[services.auth] {e}")
|
print(f"[services.auth] {e}")
|
||||||
|
|
||||||
if not user_id:
|
if not user_id:
|
||||||
raise HTTPUnauthorized(text="Please, login first")
|
raise HTTPException(status_code=401,detail="Unauthorized")
|
||||||
|
|
||||||
|
|
||||||
def login_required(f):
|
def login_required(f):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user