summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/auth.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-03 21:18:10 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-03 21:18:10 -0800
commit03df0b8a6d1285fa4aa17e6c4216dd2716a9ac47 (patch)
treece6cc7f35a038ff5da26b86184d83441604de024 /python/fatcat_web/auth.py
parent422a8cc47489aa44b852ff0add1ef6ea63cfc1ff (diff)
downloadfatcat-03df0b8a6d1285fa4aa17e6c4216dd2716a9ac47.tar.gz
fatcat-03df0b8a6d1285fa4aa17e6c4216dd2716a9ac47.zip
account page and renaming
Diffstat (limited to 'python/fatcat_web/auth.py')
-rw-r--r--python/fatcat_web/auth.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/python/fatcat_web/auth.py b/python/fatcat_web/auth.py
index 385f5c49..c6e6f04c 100644
--- a/python/fatcat_web/auth.py
+++ b/python/fatcat_web/auth.py
@@ -1,10 +1,17 @@
from flask import Flask, render_template, send_from_directory, request, \
- url_for, abort, g, redirect, jsonify, session
-from fatcat_web import login_manager, api
+ url_for, abort, g, redirect, jsonify, session, flash
+from fatcat_web import login_manager, api, Config
from flask_login import logout_user, login_user, UserMixin
import pymacaroons
+import fatcat_client
+def auth_api(token):
+ conf = fatcat_client.Configuration()
+ conf.api_key["Authorization"] = token
+ conf.api_key_prefix["Authorization"] = "Bearer"
+ conf.host = Config.FATCAT_API_HOST
+ return fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))
def handle_logout():
logout_user()
@@ -31,7 +38,7 @@ def handle_token_login(token):
session['api_token'] = token
session['editor'] = editor
login_user(load_user(editor_id))
- return redirect("/")
+ return redirect("/auth/account")
# This will need to login/signup via fatcatd API, then set token in session
def handle_oauth(remote, token, user_info):
@@ -70,6 +77,7 @@ def load_user(editor_id):
token = session['api_token']
user = UserMixin()
user.id = editor_id
+ user.editor_id = editor_id
user.username = editor['username']
user.token = token
return user