diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-04-04 11:21:41 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-04-04 11:21:41 -0700 |
commit | c4591cd12298cc03cd96af829a9a007d83d4e537 (patch) | |
tree | 1a5e47037bb2294a34841f0a7f7b04da3fccc369 /python/fatcat_web/auth.py | |
parent | 005236655dec1cb3f7409724a711a19b52aa9108 (diff) | |
parent | edb9c1b85f367a50957dc0423c3104b900c7e92c (diff) | |
download | fatcat-c4591cd12298cc03cd96af829a9a007d83d4e537.tar.gz fatcat-c4591cd12298cc03cd96af829a9a007d83d4e537.zip |
Merge branch 'bnewbold-forms'
Diffstat (limited to 'python/fatcat_web/auth.py')
-rw-r--r-- | python/fatcat_web/auth.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/python/fatcat_web/auth.py b/python/fatcat_web/auth.py index 1953151b..7f51b970 100644 --- a/python/fatcat_web/auth.py +++ b/python/fatcat_web/auth.py @@ -5,7 +5,7 @@ import pymacaroons from flask import Flask, render_template, send_from_directory, request, \ url_for, abort, g, redirect, jsonify, session, flash from flask_login import logout_user, login_user, UserMixin -from fatcat_web import login_manager, api, priv_api, Config +from fatcat_web import login_manager, app, api, priv_api, Config import fatcat_client def handle_logout(): @@ -20,6 +20,7 @@ def handle_token_login(token): m = pymacaroons.Macaroon.deserialize(token) except pymacaroons.exceptions.MacaroonDeserializationException: # TODO: what kind of Exceptions? + app.log.warn("auth fail: MacaroonDeserializationException") return abort(400) # extract editor_id editor_id = None @@ -28,6 +29,7 @@ def handle_token_login(token): if caveat.startswith(b"editor_id = "): editor_id = caveat[12:].decode('utf-8') if not editor_id: + app.log.warn("auth fail: editor_id missing in macaroon") abort(400) # fetch editor info editor = api.get_editor(editor_id) @@ -93,12 +95,11 @@ def handle_ia_xauth(email, password): try: flash("Internet Archive email/password didn't match: {}".format(resp.json()['values']['reason'])) except: - print("IA XAuth fail: {}".format(resp.content)) + app.log.warn("IA XAuth fail: {}".format(resp.content)) return render_template('auth_ia_login.html', email=email), resp.status_code elif resp.status_code != 200: flash("Internet Archive login failed (internal error?)") - # TODO: log.warn - print("IA XAuth fail: {}".format(resp.content)) + app.log.warn("IA XAuth fail: {}".format(resp.content)) return render_template('auth_ia_login.html', email=email), resp.status_code # Successful login; now fetch info... @@ -112,8 +113,7 @@ def handle_ia_xauth(email, password): }) if resp.status_code != 200: flash("Internet Archive login failed (internal error?)") - # TODO: log.warn - print("IA XAuth fail: {}".format(resp.content)) + app.log.warn("IA XAuth fail: {}".format(resp.content)) return render_template('auth_ia_login.html', email=email), resp.status_code ia_info = resp.json()['values'] @@ -139,5 +139,6 @@ def load_user(editor_id): user.id = editor_id user.editor_id = editor_id user.username = editor['username'] + user.is_admin = editor['is_admin'] user.token = token return user |