Compare commits
2 commits
d7f9a309b1
...
2eb2a7701d
Author | SHA1 | Date | |
---|---|---|---|
2eb2a7701d | |||
8928f691e1 |
2 changed files with 11 additions and 6 deletions
|
@ -6,5 +6,7 @@
|
||||||
"dbpass":"choose a good password for the mysql user and put it here",
|
"dbpass":"choose a good password for the mysql user and put it here",
|
||||||
"dbname":"curiousgreg",
|
"dbname":"curiousgreg",
|
||||||
"min_time_between_checks":1,
|
"min_time_between_checks":1,
|
||||||
"max_time_between_checks":60
|
"max_time_between_checks":60,
|
||||||
|
"base_uri":"http://localhost:5000",
|
||||||
|
"debug":false
|
||||||
}
|
}
|
||||||
|
|
11
web.py
11
web.py
|
@ -90,9 +90,12 @@ def home():
|
||||||
return redirect(url_for('main'))
|
return redirect(url_for('main'))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/debug') #TODO: remove this before making the site live ;p
|
@app.route('/debug')
|
||||||
def print_debug_info():
|
def print_debug_info():
|
||||||
|
if cfg['debug']:
|
||||||
return json.dumps(session._get_current_object())
|
return json.dumps(session._get_current_object())
|
||||||
|
else:
|
||||||
|
return redirect('/home')
|
||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
def reset_session():
|
def reset_session():
|
||||||
|
@ -121,11 +124,11 @@ def internal_auth_a(): #TODO: prevent these endpoints from being spammed somehow
|
||||||
api_base_url=session['instance'],
|
api_base_url=session['instance'],
|
||||||
scopes=scopes,
|
scopes=scopes,
|
||||||
website=cfg['website'],
|
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'])
|
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)
|
return redirect(url, code=307)
|
||||||
|
|
||||||
|
@ -133,7 +136,7 @@ def internal_auth_a(): #TODO: prevent these endpoints from being spammed somehow
|
||||||
def internal_auth_b():
|
def internal_auth_b():
|
||||||
#write details to DB
|
#write details to DB
|
||||||
client = Mastodon(client_id=session['client_id'], client_secret=session['client_secret'], api_base_url=session['instance'])
|
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()
|
acct_info = client.account_verify_credentials()
|
||||||
session['username'] = acct_info['username']
|
session['username'] = acct_info['username']
|
||||||
session['avi'] = acct_info['avatar']
|
session['avi'] = acct_info['avatar']
|
||||||
|
|
Loading…
Reference in a new issue