From 7479b9facafb9118cd8b529b70156715d320e500 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Wed, 30 Sep 2020 22:49:22 -0400 Subject: [PATCH] Force logout and clear before social auth login --- .../thirdPartySignOn.controller.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/awx/ui/client/src/login/loginModal/thirdPartySignOn/thirdPartySignOn.controller.js b/awx/ui/client/src/login/loginModal/thirdPartySignOn/thirdPartySignOn.controller.js index 8222eb8d44..4593344ad3 100644 --- a/awx/ui/client/src/login/loginModal/thirdPartySignOn/thirdPartySignOn.controller.js +++ b/awx/ui/client/src/login/loginModal/thirdPartySignOn/thirdPartySignOn.controller.js @@ -11,8 +11,8 @@ * Controller for handling third party supported login options. */ -export default ['$window', '$scope', 'thirdPartySignOnService', - function ($window, $scope, thirdPartySignOnService) { +export default ['$window', '$scope', 'thirdPartySignOnService', '$cookies', 'Authorization', + function ($window, $scope, thirdPartySignOnService, $cookies, Authorization) { thirdPartySignOnService( {scope: $scope, url: "api/v2/auth/"}).then(function (data) { @@ -29,8 +29,16 @@ export default ['$window', '$scope', 'thirdPartySignOnService', }); $scope.goTo = function(link) { - // this is used because $location only lets you navigate inside - // the "/#/" path, and these are API urls. - $window.location.href = link; + // clear out any prior auth state that might exist (e.g: from other + // tabs, etc.) before redirecting to the auth service + Authorization.logout().then(() => { + angular.forEach($cookies.getAll(), (val, name) => { + $cookies.remove(name); + }); + $window.location.reload(); + // this is used because $location only lets you navigate inside + // the "/#/" path, and these are API urls. + $window.location.href = link; + }); }; }];