Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added a Setting for LOGOUT_REDIRECT_URLNAME #33

Merged
merged 2 commits into from

2 participants

@dstufft

This setting is used to determine where the user will be redirected
to after they successfully log out of the site.

@dstufft dstufft Add a LOGOUT_REDIRECT_URLNAME setting for the logout view
This setting is used to determine where the user will be redirected
to after they successfully log out of the site.
f7c9cec
@dstufft

By default for existing Projects this will do nothing. But if they define either a LOGOUT_REDIRECT_URLNAME, or LOGOUT_REDIRECT_URL setting then logout will redirect to that page. All current projects settings.py have been updated to have this setting by default.

@paltman
Owner

Don, can you please update the commit to just use LOGOUT_REDIRECT_URLNAME instead of having both settings? I'll merge and release a new dev release ASAP after you update the pull request. Thanks!

@dstufft

I can do that, however I did it this way to match the available settings for login.

See: https://github.com/pinax/pinax/blob/master/pinax/apps/account/views.py#L74

I thought it would make more sense to support the same settings for both views?

@paltman paltman merged commit bd88077 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 29, 2011
  1. @dstufft

    Add a LOGOUT_REDIRECT_URLNAME setting for the logout view

    dstufft authored
    This setting is used to determine where the user will be redirected
    to after they successfully log out of the site.
Commits on Oct 31, 2011
  1. @dstufft
This page is out of date. Refresh to see the latest.
View
2  pinax/apps/account/urls.py
@@ -19,7 +19,7 @@
url(r"^password_delete/done/$", "django.views.generic.simple.direct_to_template", {"template": "account/password_delete_done.html"}, name="acct_passwd_delete_done"),
url(r"^timezone/$", "pinax.apps.account.views.timezone_change", name="acct_timezone_change"),
url(r"^language/$", "pinax.apps.account.views.language_change", name="acct_language_change"),
- url(r"^logout/$", "django.contrib.auth.views.logout", {"template_name": "account/logout.html"}, name="acct_logout"),
+ url(r"^logout/$", "pinax.apps.account.views.logout", {"template_name": "account/logout.html"}, name="acct_logout"),
url(r"^confirm_email/(\w+)/$", "emailconfirmation.views.confirm_email", name="acct_confirm_email"),
url(r"^password_reset/$", "pinax.apps.account.views.password_reset", name="acct_passwd_reset"),
url(r"^password_reset/done/$", "pinax.apps.account.views.password_reset_done", name="acct_passwd_reset_done"),
View
11 pinax/apps/account/views.py
@@ -12,6 +12,7 @@
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.contrib.auth.tokens import default_token_generator
+from django.contrib.auth.views import logout as django_logout
from emailconfirmation.models import EmailAddress, EmailConfirmation
@@ -105,6 +106,16 @@ def login(request, **kwargs):
return render_to_response(template_name, RequestContext(request, ctx))
+def logout(request, next_page=None, **kwargs):
+ # Simple Wrapper around django.contrib.auth.views.logout to default
+ # next_page based off the setting LOGOUT_REDIRECT_URLNAME.
+
+ if next_page is None and hasattr(settings, "LOGOUT_REDIRECT_URLNAME"):
+ next_page = reverse(settings.LOGOUT_REDIRECT_URLNAME)
+
+ return django_logout(request, next_page, **kwargs)
+
+
def signup(request, **kwargs):
form_class = kwargs.pop("form_class", SignupForm)
View
1  pinax/projects/account_project/settings.py
@@ -186,6 +186,7 @@
LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "what_next"
+LOGOUT_REDIRECT_URLNAME = "home"
EMAIL_CONFIRMATION_DAYS = 2
EMAIL_DEBUG = DEBUG
View
1  pinax/projects/basic_project/settings.py
@@ -202,6 +202,7 @@
LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "what_next"
+LOGOUT_REDIRECT_URLNAME = "home"
EMAIL_CONFIRMATION_DAYS = 2
EMAIL_DEBUG = DEBUG
View
1  pinax/projects/blog_project/settings.py
@@ -188,6 +188,7 @@
LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "what_next"
+LOGOUT_REDIRECT_URLNAME = "home"
EMAIL_CONFIRMATION_DAYS = 2
EMAIL_DEBUG = DEBUG
Something went wrong with that request. Please try again.