From 3e96366887ca04cc19cc8d5f87bacf68f0b100b1 Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 5 Mar 2024 14:39:47 +0300 Subject: [PATCH] less-scope-exception-2 --- resolvers/reader.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resolvers/reader.py b/resolvers/reader.py index 305ac307..51bffd3c 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -69,11 +69,13 @@ async def get_shout(_, info, slug=None, shout_id=None): ] = results if not shout.published_at: + logger.debug('editing shout which is not published yet') user_id = info.context.get('user_id', '') roles = info.context.get('roles', []) author = session.query(Author).filter(Author.user == user_id).first() if not isinstance(author, Author): + logger.warn('author is not found') raise HTTPException( 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 'editor' not in roles ): + logger.warn('author have no permissions to read this not published shout') raise HTTPException( status_code=401, detail='shout is not published yet' )