api-server-flask
api-server-flask copied to clipboard
`token_required` decorator does not work correctly on instance methods
trafficstars
The current_user is passed into the decorated function first, switching places with self:
https://github.com/app-generator/api-server-flask/blob/748432027dcdb512cf76a6b45100db2c2c3ef1eb/api/routes.py#L76
A possible fix would be to retain the first param in the inner decorator function:
def token_required(f):
@wraps(f)
def decorator(ref, *args, **kwargs):
...
# call with ref
return f(ref, current_user, *args, **kwargs)
But this will fail on regular functions. Probably inspect could be used to make it general.