Skip to content

Commit ddd9325

Browse files
committed
Add demo app changes to maintain persistence
1 parent f520d0e commit ddd9325

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

packages/auth/demo/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@
853853
</div>
854854
<div class="tab-pane" id="tab-byo-ciam-content">
855855
<h2>Sign in with your CIAM token</h2>
856+
<div id="firebase-token-status">No CIAM token found. User not logged in.</div>
856857
<input type="text" id="byo-ciam-token"
857858
class="form-control" placeholder="Enter CIAM token" />
858859
<button class="btn btn-block btn-primary"

packages/auth/demo/src/index.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,7 @@ function onRefreshToken() {
13051305
function onSignOut() {
13061306
setLastUser(auth.currentUser);
13071307
auth.signOut().then(signOut, onAuthError);
1308+
regionalAuth.signOut();
13081309
}
13091310

13101311
/**
@@ -1520,16 +1521,17 @@ async function exchangeCIAMToken(token) {
15201521
function onExchangeToken(event) {
15211522
event.preventDefault();
15221523
const byoCiamInput = document.getElementById('byo-ciam-token');
1523-
const byoCiamResult = document.getElementById('byo-ciam-result');
1524+
const firebaseTokenStatus = document.getElementById('firebase-token-status');
15241525

1525-
byoCiamResult.textContent = 'Exchanging token...';
1526+
firebaseTokenStatus.textContent = 'Exchanging token...';
15261527

15271528
exchangeCIAMToken(byoCiamInput.value)
15281529
.then(response => {
1529-
byoCiamResult.textContent = response;
1530+
firebaseTokenStatus.textContent = '✅ Firebase token is set: ' + response;
15301531
console.log('Token:', response);
15311532
})
15321533
.catch(error => {
1534+
(firebaseTokenStatus.textContent = 'Error exchanging token: '), error;
15331535
console.error('Error exchanging token:', error);
15341536
});
15351537
}
@@ -2091,6 +2093,18 @@ function initApp() {
20912093
tenantConfig: tenantConfig
20922094
});
20932095

2096+
const firebaseTokenStatus = document.getElementById('firebase-token-status');
2097+
setTimeout(() => {
2098+
if (regionalAuth.firebaseToken) {
2099+
firebaseTokenStatus.textContent =
2100+
'✅ Firebase token is set: ' + regionalAuth.firebaseToken.token;
2101+
} else {
2102+
firebaseTokenStatus.textContent =
2103+
'No CIAM token found. User not logged in.';
2104+
}
2105+
console.log('firebaseToken after delay: ', regionalAuth.firebaseToken);
2106+
}, 1000);
2107+
20942108
tempApp = initializeApp(
20952109
{
20962110
apiKey: config.apiKey,

0 commit comments

Comments
 (0)