From 208e08410f9715f332d0ac715cb2c6770737617b Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 30 Jan 2015 16:01:22 -0500 Subject: [PATCH] Websocket would connect before login The websockets would make a connection before login when the user refreshes the login page. I believe this was happening on upgrade too. --- awx/ui/static/js/app.js | 5 +++++ awx/ui/static/lib/ansible/AuthService.js | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index a777d252c3..571741ee9c 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -631,6 +631,11 @@ angular.module('Tower', [ } else { // If browser refresh, set the user_is_superuser value $rootScope.user_is_superuser = Authorization.getUserInfo('is_superuser'); + // when the user refreshes we want to open the socket, except if the user is on the login page, which should happen after the user logs in (see the AuthService module for that call to OpenSocket) + if($location.$$url !== '/login'){ + $rootScope.$emit('OpenSocket'); + } + } activateTab(); diff --git a/awx/ui/static/lib/ansible/AuthService.js b/awx/ui/static/lib/ansible/AuthService.js index ce8b4f73b1..6e3ae7647a 100644 --- a/awx/ui/static/lib/ansible/AuthService.js +++ b/awx/ui/static/lib/ansible/AuthService.js @@ -141,7 +141,6 @@ angular.module('AuthService', ['ngCookies', 'Utilities']) restoreUserInfo: function () { $rootScope.current_user = $cookieStore.get('current_user'); - // $rootScope.$emit('OpenSocket'); }, getUserInfo: function (key) {