error-handle-create-shout
All checks were successful
Deploy on push / deploy (push) Successful in 24s
All checks were successful
Deploy on push / deploy (push) Successful in 24s
This commit is contained in:
parent
a93fa7fb18
commit
4a57866c3d
|
@ -40,7 +40,8 @@ async def get_shouts_drafts(_, info):
|
||||||
@mutation.field('create_shout')
|
@mutation.field('create_shout')
|
||||||
@login_required
|
@login_required
|
||||||
def create_shout(_, info, inp):
|
def create_shout(_, info, inp):
|
||||||
user_id = info.context['user_id']
|
user_id = info.context.get('user_id')
|
||||||
|
if user_id:
|
||||||
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 isinstance(author, Author):
|
if isinstance(author, Author):
|
||||||
|
@ -102,7 +103,7 @@ def create_shout(_, info, inp):
|
||||||
|
|
||||||
return {'shout': shout}
|
return {'shout': shout}
|
||||||
|
|
||||||
return {'error': 'cant create shout'}
|
return {'error': 'cant create shout' if user_id else 'unauthorized'}
|
||||||
|
|
||||||
|
|
||||||
def patch_main_topic(session, main_topic, shout):
|
def patch_main_topic(session, main_topic, shout):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user