Skip to content

Commit 7d257fc

Browse files
authored
Merge pull request #67 from eresearchqut/ERP-3472_Resiliency
[ERP-3472] Build in some resilience where the user doesn't have a valid session.
2 parents f2aecb9 + a269f7b commit 7d257fc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

frontend/context/app-init-context.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ export const AppInitProvider: FunctionComponent<PropsWithChildren> = ({
4848

4949
if (rumAccessToken && realm) {
5050
getCurrentSession()
51-
.then(({ tokens }) => {
52-
const username = tokens?.idToken?.payload?.[
53-
"cognito:username"
54-
] as string;
55-
51+
.then(
52+
({ tokens }) =>
53+
tokens?.idToken?.payload?.["cognito:username"] as string,
54+
)
55+
.catch(() => "")
56+
.then((username) => {
5657
const splunkConfig = {
5758
realm,
5859
rumAccessToken,
@@ -67,7 +68,7 @@ export const AppInitProvider: FunctionComponent<PropsWithChildren> = ({
6768
});
6869
SplunkSessionRecorder.init(splunkConfig);
6970
})
70-
.then(() => {
71+
.finally(() => {
7172
setIsInitialised(true);
7273
});
7374
} else {

0 commit comments

Comments
 (0)