Problems with the creation of a authentication decorator for Flask Problems with the creation of a authentication decorator for Flask flask flask

Problems with the creation of a authentication decorator for Flask


The problem is with the elif statement in funcWrapper:

elif result[0][0] == apiKey:   return func

func is a callable object i.e the original function wrapped by requestAuth, which, in this case, is unregisterApi. Instead, call func to return the valid type rather than the object instance itself:

elif result[0][0] == apiKey:   return func()

Also, bear in mind that if both the if and elif statements fail, None will be returned by funcWrapper, raising the original error again. Thus, you may want to reconsider how you wish to handle that particular case.