From 4ad2af30cff93a92fb20caf854d10678d9b1405c Mon Sep 17 00:00:00 2001 From: gconsidine Date: Fri, 22 Sep 2017 17:58:16 -0400 Subject: [PATCH] Fix login and authorization token errors * Remove extraneous quotes when authroization token is retrieved from a cookie * Fix thrown error when invalid creds are supplied on login due to attempt to access property of an undefined value --- .../authenticationServices/authentication.service.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/login/authenticationServices/authentication.service.js b/awx/ui/client/src/login/authenticationServices/authentication.service.js index 4f2d826f7a..f7c6f565a0 100644 --- a/awx/ui/client/src/login/authenticationServices/authentication.service.js +++ b/awx/ui/client/src/login/authenticationServices/authentication.service.js @@ -45,7 +45,13 @@ export default }, getToken: function () { - return ($rootScope.token) ? $rootScope.token : $cookies.get('token'); + if ($rootScope.token) { + return $rootScope.token; + } + + let token = $cookies.get('token'); + + return token ? token.replace(/"/g, '') : undefined; }, retrieveToken: function (username, password) { @@ -101,7 +107,7 @@ export default $rootScope.lastPath = '/home'; } x = Store('sessionTime'); - if ($rootScope.current_user) { + if ($rootScope.current_user && x && x[$rootScope.current_user.id]) { x[$rootScope.current_user.id].loggedIn = false; } Store('sessionTime', x);