From b1d0bb4ad562a9f15d29eccc81040465d1f037a5 Mon Sep 17 00:00:00 2001 From: Benjamin Armintor Date: Sat, 1 Feb 2025 00:15:39 -0500 Subject: [PATCH] COLUMBIA: Auth2 external access services use a well-known key to track auth --- src/state/selectors/auth.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/state/selectors/auth.js b/src/state/selectors/auth.js index c38a10b61..88342266c 100644 --- a/src/state/selectors/auth.js +++ b/src/state/selectors/auth.js @@ -81,15 +81,17 @@ export const selectCurrentAuthServices = createSelector( const probeServices = anyProbeServices(resource); const probeServiceServices = flatten(probeServices.map(p => Utils.getServices(p))); + const allAuthServices = resourceServices.concat(probeServiceServices); + for (const authProfile of serviceProfiles) { - const profiledAuthServices = resourceServices.concat(probeServiceServices).filter( + const profiledAuthServices = allAuthServices.filter( p => authProfile.profile === p.getProfile(), ); for (const service of profiledAuthServices) { lastAttemptedService = service; // external service may have no id to track by (auth1 vs auth2) - const serviceKey = (authProfile.external) ? (service?.id || 'external') : service?.id; + const serviceKey = (authProfile.external) ? 'external' : service?.id; if (!auth[serviceKey] || auth[serviceKey].isFetching || auth[serviceKey].ok) { return service; @@ -103,10 +105,11 @@ export const selectCurrentAuthServices = createSelector( return Object.values(currentAuthServices.reduce((h, service) => { if (!service) return h; const external = serviceProfiles.filter(x => x.external).find(s => (s.profile === service.getProfile())); - const serviceKey = (external) ? (service.id || 'external') : service.id; + const serviceKey = (external) ? 'external' : service.id; if (!h[serviceKey]) { h[serviceKey] = service; // eslint-disable-line no-param-reassign } + return h; }, {})); },