summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Okhrimenko <vokhrimenko@mirantis.com>2014-10-22 11:23:04 +0300
committerVlad Okhrimenko <vokhrimenko@mirantis.com>2014-10-22 12:06:09 +0300
commit2a29dfa4be84918528c594505d55214c3c93b097 (patch)
tree0f8f7c6713a66aa7fb95f9a60fc5051b04f3277b
parentd26697293200f6c58ae9ef7cd213935ef83280f3 (diff)
downloaddjango_openstack_auth-2a29dfa4be84918528c594505d55214c3c93b097.tar.gz
Fix inability to switch region via Switch Region dropdown
Prevent logged-in users redirect in case 'login' view is used for switching the regions via modal form. Change-Id: I47f26eea19e577998c7e3906a51900b51024eb43 Related-Bug: #1381413
-rw-r--r--openstack_auth/views.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/openstack_auth/views.py b/openstack_auth/views.py
index e7ea1e8..938d720 100644
--- a/openstack_auth/views.py
+++ b/openstack_auth/views.py
@@ -49,14 +49,15 @@ LOG = logging.getLogger(__name__)
@never_cache
def login(request, template_name=None, extra_context=None, **kwargs):
"""Logs a user in using the :class:`~openstack_auth.forms.Login` form."""
- # If the user is already authenticated, redirect them to the
- # dashboard straight away, unless the 'next' parameter is set as it
- # usually indicates requesting access to a page that requires different
- # permissions.
- if (request.user.is_authenticated() and
- auth.REDIRECT_FIELD_NAME not in request.GET and
- auth.REDIRECT_FIELD_NAME not in request.POST):
- return shortcuts.redirect(settings.LOGIN_REDIRECT_URL)
+ if not request.is_ajax():
+ # If the user is already authenticated, redirect them to the
+ # dashboard straight away, unless the 'next' parameter is set as it
+ # usually indicates requesting access to a page that requires different
+ # permissions.
+ if (request.user.is_authenticated() and
+ auth.REDIRECT_FIELD_NAME not in request.GET and
+ auth.REDIRECT_FIELD_NAME not in request.POST):
+ return shortcuts.redirect(settings.LOGIN_REDIRECT_URL)
# Get our initial region for the form.
initial = {}