Anonymous avatar Anonymous committed e3f0bd0

allow user to set default redirect_page or template in signout. Fix
issue #27.

Comments (0)

Files changed (2)

django_authopenid/views.py

     }, context_instance=_build_context(request, extra_context=extra_context))
 
 @login_required
-def signout(request):
+def signout(request, next_page=None, template_name='registration/logged_out.html'):
     """
     signout from the website. Remove openid from session and kill it.
     """
         del request.session['openid']
     except KeyError:
         pass
-    next = clean_next(request.GET.get('next'))
+    next = request.GET.get('next')
     logout(request)
+    if next is not None:
+        return HttpResponseRedirect(next)
     
-    return HttpResponseRedirect(next)
+    if next_page is None:
+        return render(template_name, {
+            'title': _('Logged out')}, context_instance=RequestContext(request))
+            
+    return HttpResponseRedirect(next_page or request.path)
     
 def xrdf(request, template_name='authopenid/yadis.xrdf'):
     """ view used to process the xrdf file"""

example/templates/home.html

 <ul>
 	<li><a href="{% url user_associate %}">Associate a new openid</a></li>
 	<li><a href="{% url auth_password_change %}">Change password</a></li>
-  	<li><a href="{% url user_signout %}">signout</a></li>
+  	<li><a href="{% url user_signout %}?next=/">signout</a></li>
 </ul>
 {% else %}
 <h2>Make a choice:</h2>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.