Jelajahi Sumber

HUE-7440 [core] Remove load balancer cookie on login if not authenticated

To rebalance to a new Hue each time a user re-logins.
Check if the user is authenticated so that a relogin while already
logged in does not re-balance.
Romain Rigaux 8 tahun lalu
induk
melakukan
5ac0e0c
1 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 6 1
      desktop/core/src/desktop/auth/views.py

+ 6 - 1
desktop/core/src/desktop/auth/views.py

@@ -173,7 +173,7 @@ def dt_login(request, from_modal=False):
   if from_modal:
     renderable_path = 'login_modal.mako'
 
-  return render(renderable_path, request, {
+  response = render(renderable_path, request, {
     'action': urlresolvers.reverse('desktop.auth.views.dt_login'),
     'form': first_user_form or auth_form,
     'next': redirect_to,
@@ -183,6 +183,11 @@ def dt_login(request, from_modal=False):
     'active_directory': is_active_directory
   })
 
+  if not request.user.is_authenticated():
+    response.delete_cookie(LOAD_BALANCER_COOKIE) # Note: might be re-balanced to another Hue on login.
+
+  return response
+
 
 def dt_logout(request, next_page=None):
   """Log out the user"""