Created
July 19, 2019 03:36
-
-
Save saltukalakus/6d17f3ee3fc8ac50c9be51016d1eac82 to your computer and use it in GitHub Desktop.
Check is the user is already authenticated on other site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function() { | |
webAuth = new auth0.WebAuth({ | |
domain: 'saltuk-wordpress.auth0.com', | |
redirectUri: 'http://dev-auth0-test1.pantheonsite.io/index.php?auth0=1', | |
clientID: 'SCNHLB4vHvQlTKazudZO87LDikCyrP6s', | |
responseType: 'token id_token', | |
}); | |
if (document.cookie.match(/^(.*;)?\s*CheckedSessionCookie\s*=\s*[^;]+(.*)?$/) === null) { | |
webAuth.checkSession({}, function (err, result){ | |
if (!err) { | |
// There is a valid session from another app so let's redirect after setting the | |
// session state checked cookie to prevent a redirect loop | |
document.cookie="CheckedSessionCookie=true"; | |
location.href='http://dev-auth0-test1.pantheonsite.io/wp-login.php/'; | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment