From a054f4441e74ac3dd4d913ebe2a89c2ed7aece2e Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Wed, 12 Oct 2016 17:36:42 +0200 Subject: [PATCH] Fixed handling of unset L2P_APIKEY, closes #68 --- l2pauth.py | 6 ++++++ server.py | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/l2pauth.py b/l2pauth.py index 6713deb..d658ee4 100644 --- a/l2pauth.py +++ b/l2pauth.py @@ -16,6 +16,8 @@ def oauthget(endpoint, **args): @app.route('/l2pauth') def start_l2pauth(): + if 'L2P_APIKEY' not in config: + return render_template("500.html"), 500 code = oauthget('code', scope='l2p2013.rwth') session['oauthcode'] = code['device_code'] session['oauthscope'] = 'l2p' @@ -23,6 +25,8 @@ def start_l2pauth(): @app.route('/rwthauth') def start_rwthauth(): + if 'L2P_APIKEY' not in config: + return render_template("500.html"), 500 code = oauthget('code', scope='userinfo.rwth') session['oauthcode'] = code['device_code'] session['oauthscope'] = 'rwth' @@ -30,6 +34,8 @@ def start_rwthauth(): @app.before_request def finish_oauth(): + if 'L2P_APIKEY' not in config: + return if 'oauthcode' not in session or 'oauthscope' not in session: return token = oauthget('token', code=session['oauthcode'], grant_type='device') diff --git a/server.py b/server.py index e1613b1..3945c3a 100644 --- a/server.py +++ b/server.py @@ -572,7 +572,6 @@ import importer import sorter if 'ICAL_URL' in config: import meetings -if 'L2P_APIKEY' in config: - import l2pauth +import l2pauth import jobs import timetable -- GitLab