-
Notifications
You must be signed in to change notification settings - Fork 334
fix(clerk-js,types): Use intent parameter to reload resource #5553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@clerk/clerk-js': patch | ||
'@clerk/types': patch | ||
--- | ||
|
||
Optionally handle the `intent` parameter on SSO redirects to reload specific resources. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,7 +24,9 @@ export const SSOCallbackCard = (props: HandleOAuthCallbackParams | HandleSamlCal | |||||
React.useEffect(() => { | ||||||
let timeoutId: ReturnType<typeof setTimeout>; | ||||||
if (__internal_setActiveInProgress !== true) { | ||||||
handleRedirectCallback({ ...props }, navigate).catch(e => { | ||||||
const intent = new URLSearchParams(window.location.search).get('intent'); | ||||||
const reloadResource = intent === 'signIn' || intent === 'signUp' ? intent : undefined; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do this ? Or is
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TypeScript won't narrow from |
||||||
handleRedirectCallback({ ...props, reloadResource }, navigate).catch(e => { | ||||||
handleError(e, [], card.setError); | ||||||
timeoutId = setTimeout(() => void navigate('../'), 4000); | ||||||
}); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe use the params from the router instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the hash and virtual routers, the queryString isn't derived from
window.location.search
, which is where theintent
param is going to be. For example, this is the SSO callback route when using the hash router:In this example,
window.location.search
is?intent=sign-in
, but the value ofqueryString
fromuseRotuer
is""
.Alternatively, we could append the
intent
parameter to different locations based on the router used, but I felt that was a little too much additional complexity in exchange for basically no additional functionality.