From 8928f691e1bd965417fd03e662224eac9330f21c Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 13 Nov 2018 22:08:12 +1000 Subject: [PATCH] made base URL configurable --- meta.sample.json | 3 ++- web.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/meta.sample.json b/meta.sample.json index 24d123e..b5f6663 100644 --- a/meta.sample.json +++ b/meta.sample.json @@ -6,5 +6,6 @@ "dbpass":"choose a good password for the mysql user and put it here", "dbname":"curiousgreg", "min_time_between_checks":1, - "max_time_between_checks":60 + "max_time_between_checks":60, + "base_uri":"http://localhost:5000" } diff --git a/web.py b/web.py index 9f9f0f8..65202c7 100755 --- a/web.py +++ b/web.py @@ -121,11 +121,11 @@ def internal_auth_a(): #TODO: prevent these endpoints from being spammed somehow api_base_url=session['instance'], scopes=scopes, website=cfg['website'], - redirect_uris=['https://cg.lynnesbian.space/internal/auth_b', 'http://localhost:5000/internal/auth_b'] + redirect_uris=['{}/internal/auth_b'.format(cfg['base_uri'])] ) client = Mastodon(client_id=session['client_id'], client_secret=session['client_secret'], api_base_url=session['instance']) - url = client.auth_request_url(client_id=session['client_id'], redirect_uris='http://localhost:5000/internal/auth_b', scopes=scopes) + url = client.auth_request_url(client_id=session['client_id'], redirect_uris='{}/internal/auth_b'.format(cfg['base_uri']), scopes=scopes) return redirect(url, code=307) @@ -133,7 +133,7 @@ def internal_auth_a(): #TODO: prevent these endpoints from being spammed somehow def internal_auth_b(): #write details to DB client = Mastodon(client_id=session['client_id'], client_secret=session['client_secret'], api_base_url=session['instance']) - session['secret'] = client.log_in(code = request.args.get('code'), scopes=scopes, redirect_uri='http://localhost:5000/internal/auth_b') + session['secret'] = client.log_in(code = request.args.get('code'), scopes=scopes, redirect_uri='{}/internal/auth_b'.format(cfg['base_uri'])) acct_info = client.account_verify_credentials() session['username'] = acct_info['username'] session['avi'] = acct_info['avatar']