Merge pull request #8299 from jakemcdermott/fix-8154

Force logout and clear before social auth login

Reviewed-by: Jake McDermott <yo@jakemcdermott.me>
             https://github.com/jakemcdermott
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-10-01 17:47:12 +00:00 committed by GitHub
commit 796a61da86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
});
};
}];