aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/auth.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-02-26 11:30:18 -0800
committerBryan Newbold <bnewbold@robocracy.org>2021-02-26 12:03:32 -0800
commitfc9edfb1b65260f41f204d11bf130ceb35cb84e0 (patch)
tree3620d3c2c5b40e4b6a9c5cac7bb63f7a284eedc5 /python/fatcat_web/auth.py
parent901e4f4c23398e19e2595c374f2fa45e4773e992 (diff)
downloadfatcat-fc9edfb1b65260f41f204d11bf130ceb35cb84e0.tar.gz
fatcat-fc9edfb1b65260f41f204d11bf130ceb35cb84e0.zip
web: reduce flash() usage; have logins redirect
Diffstat (limited to 'python/fatcat_web/auth.py')
-rw-r--r--python/fatcat_web/auth.py19
1 files changed, 10 insertions, 9 deletions
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")