Force logout and clear before social auth login

This commit is contained in:
Jake McDermott 2020-09-30 22:49:22 -04:00
parent 1b6acdf84d
commit 7479b9faca
No known key found for this signature in database
GPG Key ID: 0E56ED990CDFCB4F

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