This commit is contained in:
parent
dae2c7b689
commit
02a7b64449
|
@ -1,7 +1,6 @@
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from starlette.exceptions import HTTPException
|
|
||||||
|
|
||||||
from settings import ADMIN_SECRET, AUTH_URL
|
from settings import ADMIN_SECRET, AUTH_URL
|
||||||
from services.logger import root_logger as logger
|
from services.logger import root_logger as logger
|
||||||
|
@ -29,6 +28,7 @@ async def request_data(gql, headers=None):
|
||||||
async def check_auth(req):
|
async def check_auth(req):
|
||||||
token = req.headers.get('Authorization')
|
token = req.headers.get('Authorization')
|
||||||
user_id = ''
|
user_id = ''
|
||||||
|
user_roles = []
|
||||||
if token:
|
if token:
|
||||||
# Logging the authentication token
|
# Logging the authentication token
|
||||||
logger.debug(f'{token}')
|
logger.debug(f'{token}')
|
||||||
|
@ -50,9 +50,6 @@ async def check_auth(req):
|
||||||
user_roles = user_data.get('allowed_roles')
|
user_roles = user_data.get('allowed_roles')
|
||||||
return [user_id, user_roles]
|
return [user_id, user_roles]
|
||||||
|
|
||||||
if not user_id:
|
|
||||||
raise HTTPException(status_code=401, detail='Unauthorized')
|
|
||||||
|
|
||||||
|
|
||||||
async def add_user_role(user_id):
|
async def add_user_role(user_id):
|
||||||
logger.info(f'add author role for user_id: {user_id}')
|
logger.info(f'add author role for user_id: {user_id}')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user