Skip to content

Commit 21b6f96

Browse files
committed
Demo App using Auth with LocationData
1 parent 3bc7a88 commit 21b6f96

File tree

2 files changed

+45
-31
lines changed

2 files changed

+45
-31
lines changed

packages/auth/demo/src/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,17 @@ function onApplyAuthSettingsChange() {
20462046
function initApp() {
20472047
log('Initializing app...');
20482048
app = initializeApp(config);
2049-
auth = getAuth(app);
2049+
const locationData = {location: 'us', tenantId: 'tenant-1'}
2050+
auth = initializeAuth(app, {
2051+
persistence: inMemoryPersistence,
2052+
popupRedirectResolver: browserPopupRedirectResolver,
2053+
locationData: locationData
2054+
});
2055+
// Returns already initialized instance of auth i.e. auth with LocationData.
2056+
// auth = getAuth(app);
2057+
console.log("here demo");
2058+
console.log(auth);
2059+
console.log(auth.config.apiHost);
20502060
if (USE_AUTH_EMULATOR) {
20512061
connectAuthEmulator(auth, AUTH_EMULATOR_URL);
20522062
}
@@ -2060,8 +2070,12 @@ function initApp() {
20602070
);
20612071
tempAuth = initializeAuth(tempApp, {
20622072
persistence: inMemoryPersistence,
2063-
popupRedirectResolver: browserPopupRedirectResolver
2073+
popupRedirectResolver: browserPopupRedirectResolver,
2074+
locationData: locationData
20642075
});
2076+
console.log("here demo tempAuth");
2077+
console.log(tempAuth);
2078+
console.log(tempAuth.config.apiHost);
20652079
if (USE_AUTH_EMULATOR) {
20662080
connectAuthEmulator(tempAuth, AUTH_EMULATOR_URL);
20672081
}

packages/auth/demo/src/worker/service-worker.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ function getOriginFromUrl(url: string): string {
7474
return protocol + '//' + host;
7575
}
7676

77-
self.addEventListener('install', (event: ExtendableEvent) => {
78-
// Perform install steps.
79-
event.waitUntil(async (): Promise<void> => {
80-
const cache = await caches.open(CACHE_NAME);
81-
// Add all URLs of resources we want to cache.
82-
try {
83-
await cache.addAll(urlsToCache);
84-
} catch {
85-
// Suppress error as some of the files may not be available for the
86-
// current page.
87-
}
88-
});
89-
});
77+
// self.addEventListener('install', (event: ExtendableEvent) => {
78+
// // Perform install steps.
79+
// event.waitUntil(async (): Promise<void> => {
80+
// const cache = await caches.open(CACHE_NAME);
81+
// // Add all URLs of resources we want to cache.
82+
// try {
83+
// await cache.addAll(urlsToCache);
84+
// } catch {
85+
// // Suppress error as some of the files may not be available for the
86+
// // current page.
87+
// }
88+
// });
89+
// });
9090

9191
// As this is a test app, let's only return cached data when offline.
9292
self.addEventListener('fetch', (event: FetchEvent) => {
@@ -155,19 +155,19 @@ self.addEventListener('fetch', (event: FetchEvent) => {
155155
);
156156
});
157157

158-
self.addEventListener('activate', (event: ExtendableEvent) => {
159-
// Update this list with all caches that need to remain cached.
160-
const cacheWhitelist = ['cache-v1'];
161-
event.waitUntil(async (): Promise<void> => {
162-
const cacheNames = await caches.keys();
163-
await Promise.all(
164-
cacheNames.map(cacheName => {
165-
// Check if cache is not whitelisted above.
166-
if (cacheWhitelist.indexOf(cacheName) === -1) {
167-
// If not whitelisted, delete it.
168-
return caches.delete(cacheName);
169-
}
170-
})
171-
);
172-
});
173-
});
158+
// self.addEventListener('activate', (event: ExtendableEvent) => {
159+
// // Update this list with all caches that need to remain cached.
160+
// const cacheWhitelist = ['cache-v1'];
161+
// event.waitUntil(async (): Promise<void> => {
162+
// const cacheNames = await caches.keys();
163+
// await Promise.all(
164+
// cacheNames.map(cacheName => {
165+
// // Check if cache is not whitelisted above.
166+
// if (cacheWhitelist.indexOf(cacheName) === -1) {
167+
// // If not whitelisted, delete it.
168+
// return caches.delete(cacheName);
169+
// }
170+
// })
171+
// );
172+
// });
173+
// });

0 commit comments

Comments
 (0)