This commit is contained in:
@@ -6,7 +6,6 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
from orm.author import Author
|
||||
from orm.notification import Notification as NotificationMessage, NotificationSeen
|
||||
from services.auth import check_auth
|
||||
from aiohttp.web import HTTPUnauthorized
|
||||
from services.db import local_session
|
||||
import strawberry
|
||||
from strawberry_sqlalchemy_mapper import StrawberrySQLAlchemyMapper
|
||||
@@ -141,16 +140,14 @@ class LoginRequiredMiddleware(Extension):
|
||||
context = self.execution_context.context
|
||||
req = context.get("request")
|
||||
is_authenticated, user_id = await check_auth(req)
|
||||
if not is_authenticated:
|
||||
raise HTTPUnauthorized(text="Please, login first")
|
||||
else:
|
||||
if is_authenticated:
|
||||
with local_session() as session:
|
||||
author = session.query(Author).filter(Author.user == user_id).first()
|
||||
if author:
|
||||
context["author_id"] = author.id
|
||||
if user_id:
|
||||
context["user_id"] = user_id
|
||||
context["user_id"] = user_id
|
||||
context["user_id"] = user_id or None
|
||||
|
||||
|
||||
schema = strawberry.Schema(
|
||||
|
Reference in New Issue
Block a user