Skip to content

Commit

Permalink
fix: redirect to login if session expired during settings (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Nov 8, 2024
1 parent 0173d87 commit 6fc4ebf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/elements-react/src/util/onSubmitSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
FlowType,
handleContinueWith,
handleFlowError,
isResponseError,
loginUrl,
SettingsFlow,
settingsUrl,
UpdateSettingsFlowBody,
Expand Down Expand Up @@ -72,4 +74,15 @@ export async function onSubmitSettings(
onRedirect,
}),
)
.catch((err) => {
if (isResponseError(err)) {
if (err.response.status === 401) {
return onRedirect(
loginUrl(config) + "?return_to=" + settingsUrl(config),
true,
)
}
throw err
}
})
}

0 comments on commit 6fc4ebf

Please sign in to comment.