diff options
Diffstat (limited to 'inventory')
-rw-r--r-- | inventory/api.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/inventory/api.py b/inventory/api.py index ef05e33..d374ad1 100644 --- a/inventory/api.py +++ b/inventory/api.py @@ -3,7 +3,7 @@ import functools import time from bson import ObjectId -from flask import Blueprint, jsonify, current_app, request, abort, url_for +from flask import Blueprint, jsonify, current_app, request, abort, url_for, g from flask_pymongo import PyMongo import itsdangerous import jwt @@ -67,7 +67,8 @@ def auth_required(f): user = mongo.db.users.find_one({'_id': user_id}) if not user: abort(403) - return f(user, *args, **kwargs) + g.user = user + return f(*args, **kwargs) return wrapper @@ -271,7 +272,7 @@ def auth_logout(): @app.route('/user') @auth_required -def user_info(user): +def user_info(): url = yarl.URL(current_app.config['OAUTH_URL']).parent / 'api' / 'user' response = requests.get(str(url), headers={'Authorization': request.headers.get('Authorization')}) data = response.json() |