[core] Add frontend_url and replace some root_url with frontend path for twitter callback

This commit is contained in:
Cathy Hu 2020-08-31 21:41:23 +02:00
parent 5c39720802
commit f1bc3cba8b
3 changed files with 5 additions and 3 deletions

View file

@ -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.

View file

@ -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)

View file

@ -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,