Skip to content

Commit 5a5707e

Browse files
committed
chore: temp avoid scim and org calls for Asgardeo V2 mode
1 parent f7ad555 commit 5a5707e

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
BrandingPreference,
2929
IdToken,
3030
getActiveTheme,
31+
Platform,
32+
extractUserClaimsFromIdToken,
3133
} from '@asgardeo/browser';
3234
import {FC, RefObject, PropsWithChildren, ReactElement, useEffect, useMemo, useRef, useState, useCallback} from 'react';
3335
import AsgardeoContext from './AsgardeoContext';
@@ -253,32 +255,38 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
253255
setBaseUrl(_baseUrl);
254256
}
255257

256-
try {
257-
const user: User = await asgardeo.getUser({baseUrl: _baseUrl});
258-
setUser(user);
259-
} catch (error) {
260-
// TODO: Add an error log.
261-
}
258+
// TEMPORARY: Asgardeo V2 platform does not support SCIM2, Organizations endpoints yet.
259+
// Tracker: https://github.com/asgardeo/javascript/issues/212
260+
if (config.platform !== Platform.AsgardeoV2) {
261+
setUser(extractUserClaimsFromIdToken(decodedToken));
262+
} else {
263+
try {
264+
const user: User = await asgardeo.getUser({baseUrl: _baseUrl});
265+
setUser(user);
266+
} catch (error) {
267+
// TODO: Add an error log.
268+
}
262269

263-
try {
264-
const userProfile: UserProfile = await asgardeo.getUserProfile({baseUrl: _baseUrl});
265-
setUserProfile(userProfile);
266-
} catch (error) {
267-
// TODO: Add an error log.
268-
}
270+
try {
271+
const userProfile: UserProfile = await asgardeo.getUserProfile({baseUrl: _baseUrl});
272+
setUserProfile(userProfile);
273+
} catch (error) {
274+
// TODO: Add an error log.
275+
}
269276

270-
try {
271-
const currentOrganization: Organization = await asgardeo.getCurrentOrganization();
272-
setCurrentOrganization(currentOrganization);
273-
} catch (error) {
274-
// TODO: Add an error log.
275-
}
277+
try {
278+
const currentOrganization: Organization = await asgardeo.getCurrentOrganization();
279+
setCurrentOrganization(currentOrganization);
280+
} catch (error) {
281+
// TODO: Add an error log.
282+
}
276283

277-
try {
278-
const myOrganizations: Organization[] = await asgardeo.getMyOrganizations();
279-
setMyOrganizations(myOrganizations);
280-
} catch (error) {
281-
// TODO: Add an error log.
284+
try {
285+
const myOrganizations: Organization[] = await asgardeo.getMyOrganizations();
286+
setMyOrganizations(myOrganizations);
287+
} catch (error) {
288+
// TODO: Add an error log.
289+
}
282290
}
283291

284292
// CRITICAL: Update sign-in status BEFORE setting loading to false

0 commit comments

Comments
 (0)