Merge branch 'vshulyak' into develop
[django-cas-provider.git] / cas_provider / views.py
index 4a7e9b8..d738dcd 100644 (file)
@@ -79,9 +79,12 @@ def validate(request):
     return HttpResponse("no\n\n")
 
 
-def logout(request, template_name='cas/logout.html'):
+def logout(request, template_name='cas/logout.html', auto_redirect=False):
     url = request.GET.get('url', None)
-    auth_logout(request)
+    if request.user.is_authenticated():
+        auth_logout(request)
+        if url and auto_redirect:
+            return HttpResponseRedirect(url)
     return render_to_response(template_name, {'url': url}, \
                               context_instance=RequestContext(request))