|
var TOKEN_COOKIE_KEY = "SC_TOKEN"; |
|
var token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbXAiOmZhbHNlLCJwZXJtaXNzaW9ucyI6W10sImFnZW50IjoiTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTFfMykgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzUxLjAuMjcwNC4xMDMgU2FmYXJpLzUzNy4zNiIsImV4cCI6MTQ2NzM3NDYwNCwibWVyY2hhbnRzIjpbXSwidWlkIjo5OTk5LCJpYXQiOjE0NjY3Njk4MDR9.2BYnMv2NZNNiNcJKF2n9SoIUyV3AEKdcBEvTjT0dp0g' |
|
var $cookies = angular.element(document.querySelector('html')).injector().get('$cookies'); |
|
var $location = angular.element(document.querySelector('html')).injector().get('$location'); |
|
var domains = [ |
|
'.zalan.do', |
|
'content-router-integration.adventure.zalan.do', |
|
'content-router-stage.adventure.zalan.do', |
|
'sc-integration.norris.zalan.do', |
|
'sc-stage.norris.zalan.do', |
|
'solutions.zalando.com', |
|
'content.solutions.zalando.com', |
|
$location.host() |
|
]; |
|
/** |
|
* Sets invalid SC cookies to the current domain and a host of others |
|
*/ |
|
function setBadCookies() { |
|
console.log('setting cookies') |
|
domains.forEach(function (domain, i) { |
|
console.log('set cookie ' + i +' with config: { ' + domain + ' }'); |
|
$cookies.put(TOKEN_COOKIE_KEY, token + i, { domain: domain }); |
|
}); |
|
console.log('bad cookies set? ' + !!$cookies.get(TOKEN_COOKIE_KEY)); |
|
} |
|
|
|
/** |
|
* Clears the bad cookies. Should not need to call this if using solution-center-login 1.2.2+. |
|
*/ |
|
function clearBadCookies() { |
|
$cookies = angular.element(document.querySelector('html')).injector().get('$cookies'); |
|
console.log('removing cookies'); |
|
removeCookies(); |
|
console.log('all cookies gone? ' + !$cookies.get(TOKEN_COOKIE_KEY)); |
|
|
|
function removeCookies() { |
|
$cookies.remove(TOKEN_COOKIE_KEY); // remove cookies set without options |
|
domains.forEach(function (domain) { |
|
$cookies.remove(TOKEN_COOKIE_KEY, { domain: domain }); // remove cookies set with various possible configurations |
|
}); |
|
} |
|
} |
Instructions:
setBadCookies()to create a bad cookies.clearBadCookiesto clean up.