Avoid the redirection loop (fixes #571)

This commit is contained in:
Guillaume Ayoub 2011-08-25 14:28:37 +02:00
parent 5f26c131a9
commit 4b87cb9181

View File

@ -223,12 +223,18 @@ class Application(object):
status, headers, answer = function( status, headers, answer = function(
environ, calendars, content, user) environ, calendars, content, user)
elif user and last_allowed is None: elif user and last_allowed is None:
# Good user and no calendars found, redirect user to home # Good user and no calendars found
location = "/%s/" % str(quote(user)) location = "/%s/" % str(quote(user))
log.LOGGER.info("redirecting to %s" % location) if location == environ["PATH_INFO"]:
status = client.FOUND # We already have redirected the client
headers = {"Location": location} status, headers, answer = function(
answer = "Redirecting to %s" % location environ, calendars, content, user)
else:
# Redirect the client
log.LOGGER.info("redirecting to %s" % location)
status = client.FOUND
headers = {"Location": location}
answer = "Redirecting to %s" % location
else: else:
# Unknown or unauthorized user # Unknown or unauthorized user
status = client.UNAUTHORIZED status = client.UNAUTHORIZED