Open
Description
def token_required(function):
@wraps(function)
def decorated(*args, **kwargs):
data, status = Auth.get_logged_in_user(request)
token = data.get('data')
if not token:
return data, status
return function(*args, **kwargs)
return decorated
@api.route('/<intra_id>')
@api.param('intra_id', 'The intranet identifier')
@api.response(404, 'Intranet not found.')
class Intranet(Resource):
@api.doc(security='Bearer Auth')
@api.doc('get a intranet')
@api.marshal_with(_intranet)
@token_required
def get(self, intra_id):
intranet = get_intranet(intra_id)
if not intranet:
api.abort(404)
else:
return intranet
@token_required forces a valid Authorization key, but this decorator cannot be accesed to get the token object (containing user_id, e-mail, is administrator etc.).
I can return the token object by passing it to **kwargs in the decorated function using
kwargs['token]' = token
but I'm not sure if this is the proper way to do it.
How do I properly get the token object from the decorator?
Metadata
Metadata
Assignees
Labels
No labels