def logout(request): """ Handle logout. Prevent GET requests from having side effects (such as logging the user out). Don't leave the site on a user's error message after the user logs out. """ if request.method == "POST": next_page = request.POST["next"] if re.match(urlresolvers.reverse("error"), next_page): next_page = "/" return standard_logout(request, next_page=next_page) elif request.user.is_authenticated(): return render_error(request, "Please use the logout button to log out.") return render_error(request, "Cannot logout because you are not logged in.")
def logout(request): """ Handle logout. Prevent GET requests from having side effects (such as logging the user out). Don't leave the site on a user's error message after the user logs out. """ if request.method == 'POST': next_page = request.POST['next'] if re.match(urlresolvers.reverse('error'), next_page): next_page = '/' return standard_logout(request, next_page=next_page) elif request.user.is_authenticated(): return render_error(request, 'Please use the logout button to log out.') return render_error(request, 'Cannot logout because you are not logged in.')