浏览代码

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

Ying Chen 6 年之前
父节点
当前提交
a7f9734757
共有 2 个文件被更改,包括 3 次插入0 次删除
  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

@@ -171,6 +171,8 @@ def dt_login(request, from_modal=False):
         ensure_home_directory(request.fs, request.user)
         ensure_home_directory(request.fs, request.user)
       except (IOError, WebHdfsException), e:
       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))
         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 \
   if is_active_directory and not is_ldap_option_selected and \
                   request.method == 'POST' and request.user.username != request.POST.get('username'):
                   request.method == 'POST' and request.user.username != request.POST.get('username'):

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

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