From fc9edfb1b65260f41f204d11bf130ceb35cb84e0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 26 Feb 2021 11:30:18 -0800 Subject: web: reduce flash() usage; have logins redirect --- python/fatcat_web/auth.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'python/fatcat_web/auth.py') diff --git a/python/fatcat_web/auth.py b/python/fatcat_web/auth.py index ed9f2252..74b8e2d6 100644 --- a/python/fatcat_web/auth.py +++ b/python/fatcat_web/auth.py @@ -40,7 +40,11 @@ def handle_token_login(token): session['api_token'] = token session['editor'] = editor.to_dict() login_user(load_user(editor.editor_id)) - return redirect("/auth/account") + rp = "/auth/account" + if session.get('next'): + rp = session['next'] + session.pop('next') + return redirect(rp) # This will need to login/signup via fatcatd API, then set token in session def handle_oauth(remote, token, user_info): @@ -71,13 +75,6 @@ def handle_oauth(remote, token, user_info): editor = resp.editor api_token = resp.token - if http_status == 201: - flash("Welcome to Fatcat! An account has been created for you with a temporary username; you may wish to change it under account settings") - flash("You must use the same mechanism ({}) to login in the future".format(remote.name)) - flash("Check out 'The Guide' (linked above) for an editing quickstart tutorial") - else: - flash("Welcome back {}!".format(editor.username)) - # write token and username to session session.permanent = True session['api_token'] = api_token @@ -85,7 +82,11 @@ def handle_oauth(remote, token, user_info): # call login_user(load_user(editor_id)) login_user(load_user(editor.editor_id)) - return redirect("/auth/account") + rp = "/auth/account" + if session.get('next'): + rp = session['next'] + session.pop('next') + return redirect(rp) # XXX: what should this actually be? raise Exception("didn't receive OAuth user_info") -- cgit v1.2.3