less-scope-exception-2

This commit is contained in:
Untone 2024-03-05 14:39:47 +03:00
parent c8b55d0d5b
commit 3e96366887

View File

@ -69,11 +69,13 @@ async def get_shout(_, info, slug=None, shout_id=None):
] = results ] = results
if not shout.published_at: if not shout.published_at:
logger.debug('editing shout which is not published yet')
user_id = info.context.get('user_id', '') user_id = info.context.get('user_id', '')
roles = info.context.get('roles', []) roles = info.context.get('roles', [])
author = session.query(Author).filter(Author.user == user_id).first() author = session.query(Author).filter(Author.user == user_id).first()
if not isinstance(author, Author): if not isinstance(author, Author):
logger.warn('author is not found')
raise HTTPException( raise HTTPException(
status_code=401, detail='shout is not published yet' status_code=401, detail='shout is not published yet'
) )
@ -85,6 +87,7 @@ async def get_shout(_, info, slug=None, shout_id=None):
and not any(x == author_id for x in [a.id for a in shout.authors]) and not any(x == author_id for x in [a.id for a in shout.authors])
and 'editor' not in roles and 'editor' not in roles
): ):
logger.warn('author have no permissions to read this not published shout')
raise HTTPException( raise HTTPException(
status_code=401, detail='shout is not published yet' status_code=401, detail='shout is not published yet'
) )