Browse Source

HUE-8829 [core] Fix redirect stops at /hue/accounts/login

(cherry picked from commit a7f9734757ad0635880c58d49832d6479bf9c741)

Change-Id: Id8e92fafec9acbf574125d12645f034572f9fc2d
Ying Chen 6 years ago
parent
commit
ccb42da798
2 changed files with 3 additions and 0 deletions
  1. 2 0
      desktop/core/src/desktop/auth/views.py
  2. 1 0
      desktop/core/src/desktop/tests.py

+ 2 - 0
desktop/core/src/desktop/auth/views.py

@@ -168,6 +168,8 @@ def dt_login(request, from_modal=False):
         ensure_home_directory(request.fs, request.user)
       except (IOError, WebHdfsException), e:
         LOG.error('Could not create home directory for %s user %s.' % ('OIDC' if 'OIDCBackend' in backend_names else 'SAML', request.user))
+    if request.user.is_authenticated():
+      return HttpResponseRedirect(redirect_to)
 
   if is_active_directory and not is_ldap_option_selected and \
                   request.method == 'POST' and request.user.username != request.POST.get('username'):

+ 1 - 0
desktop/core/src/desktop/tests.py

@@ -809,6 +809,7 @@ def test_ui_customizations():
 
   try:
     c = make_logged_in_client()
+    c.logout()
     resp = c.get('/hue/accounts/login/', follow=False)
     assert_true(custom_message in resp.content, resp)
     resp = c.get('/hue/about', follow=True)