From f1bc3cba8b37921415a95b22ccee02d3eeef4a43 Mon Sep 17 00:00:00 2001 From: Cathy Hu Date: Mon, 31 Aug 2020 21:41:23 +0200 Subject: [PATCH] [core] Add frontend_url and replace some root_url with frontend path for twitter callback --- kibicara/config.py | 3 ++- kibicara/platforms/twitter/webapi.py | 3 ++- kibicara/webapi/admin.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kibicara/config.py b/kibicara/config.py index f3d9e69..d6f1e6f 100644 --- a/kibicara/config.py +++ b/kibicara/config.py @@ -26,8 +26,9 @@ config = { 'database_connection': 'sqlite:////tmp/kibicara.sqlite', 'frontend_path': None, 'root_url': 'http://localhost:8000', + 'frontend_url': 'http://127.0.0.1:4200', 'production': True, - 'cors_allow_origin': 'http://localhost:4200', + 'cors_allow_origin': 'http://127.0.0.1:4200', } """ Default configuration. diff --git a/kibicara/platforms/twitter/webapi.py b/kibicara/platforms/twitter/webapi.py index b867700..8599d96 100644 --- a/kibicara/platforms/twitter/webapi.py +++ b/kibicara/platforms/twitter/webapi.py @@ -105,7 +105,8 @@ async def twitter_create(response: Response, hood=Depends(get_hood)): request_token = await get_oauth_token( config['twitter']['consumer_key'], config['twitter']['consumer_secret'], - callback_uri='http://127.0.0.1:8000/api/twitter/callback', + callback_uri=f"""""" + f"""{config["frontend_url"]}/dashboard/twitter-callback?hood={hood.id}""", ) if request_token['oauth_callback_confirmed'] != 'true': raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE) diff --git a/kibicara/webapi/admin.py b/kibicara/webapi/admin.py index 7529481..d329101 100644 --- a/kibicara/webapi/admin.py +++ b/kibicara/webapi/admin.py @@ -101,7 +101,7 @@ async def admin_register(values: BodyAdmin): admin = await Admin.objects.filter(email=values.email).all() if admin: raise HTTPException(status_code=status.HTTP_409_CONFLICT) - body = f'{config["root_url"]}/confirm?token={register_token}' + body = f'{config["frontend_url"]}/confirm?token={register_token}' logger.debug(body) email.send_email( to=values.email, subject='Confirm Account', body=body,