I've made this decorator, which results in an infinite redirect loop.
The problem is this:
args[0].redirect(users.create_login_url(args[0].request.path))
It appears to be a perfectly valid URL. So why wouldn't it properly redirect?
def admin_only(handler, *args):
def redirect_to_login(*args, **kwargs):
return args[0].redirect(users.create_login_url(args[0].request.path))
user = users.get_current_user()
if user:
if authorized(user):
return handler(args[0])
else:
logging.warning('An unauthorized user has attempted to enter an authorized page')
return redirect_to_login
else:
return redirect_to_login