From d982f975cf317932fef104f359964ccb77394bbc Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 27 Sep 2019 20:15:24 +0100 Subject: [PATCH] Fix destination after OAuth. --- app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index f433d9f..ef2e54f 100755 --- a/app.py +++ b/app.py @@ -193,6 +193,11 @@ def random_painting(): @app.route('/oauth/start') def start_oauth(): + + next_page = request.args.get('next') + if next_page: + session['after_login'] = next_page + client_key = app.config['CLIENT_KEY'] client_secret = app.config['CLIENT_SECRET'] base_url = 'https://www.wikidata.org/w/index.php' @@ -235,7 +240,8 @@ def oauth_callback(): session['owner_key'] = oauth_tokens.get('oauth_token') session['owner_secret'] = oauth_tokens.get('oauth_token_secret') - return redirect(url_for('browse_page')) + next_page = session.get('next_page') + return redirect(next_page) if next_page else random_painting() def get_username(): if 'owner_key' not in session: