Skip to content

Commit

Permalink
Add signin.ejs for single-sign-on
Browse files Browse the repository at this point in the history
  • Loading branch information
gagan0123 committed Oct 10, 2023
1 parent ae4c509 commit d4ee744
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scenarios/single-sign-on/signin.ejs
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') %>

0 comments on commit d4ee744

Please sign in to comment.