-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<%- include(commonPath + '/header.ejs') %> | ||
|
||
<div class="container mx-auto py-8"> | ||
<h1 class="text-3xl font-bold mb-4 text-center">🚧 Single Sign-On Demo</h1> | ||
<div class="text-center"> | ||
<button id="signInButton" class="bg-blue-500 text-white font-bold py-2 px-4 rounded-full inline-block">Sign In</button> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
document.getElementById('signInButton').addEventListener('click', function() { | ||
const win = window.open('<%= protocol %>://<%= domainC %>/single-sign-on/login', 'Login to SSO', 'width=500,height=500'); | ||
window.addEventListener('message', function(event) { | ||
if (event.origin !== '<%= protocol %>://<%= domainC %>') return; | ||
// Expected structure of event.data: { action: 'login', email: '[email protected]' } | ||
if (event.data.action === 'login') { | ||
// Set the cookie for domainC here using fetch or other methods. | ||
// Redirect to profile or another route as needed. | ||
document.cookie = `email=${event.data.email}; max-age=900000`; | ||
window.location.href = '/single-sign-on/profile'; | ||
} | ||
}, false); | ||
}); | ||
</script> | ||
|
||
<%- include(commonPath + '/footer.ejs') %> |