Skip to content

fix(clerk-js): Deprecate afterSignOutUrl from UserButton#3544

Merged
panteliselef merged 7 commits intomainfrom
elef/sdk-1759-deprecate-afterSignOutUrl-userbutton
Jun 28, 2024
Merged

fix(clerk-js): Deprecate afterSignOutUrl from UserButton#3544
panteliselef merged 7 commits intomainfrom
elef/sdk-1759-deprecate-afterSignOutUrl-userbutton

Conversation

@panteliselef
Copy link
Copy Markdown
Contributor

@panteliselef panteliselef commented Jun 10, 2024

Description

Fixes: DASH-183

This PR address the following issues:

  • In a single session app, user opens user profile through the user button, the developer has set afterSignOutUrl but when user deletes their account, the provided afterSignOutUrl is not respected.
  • In a multi session app, user goes to user profile, developer has set afterMultiSessionSingleSignOutUrl in user button but the user when they delete one of their accounts is not redirected to the appropriate url defined as prop.

The main issue is that we don't propagate afterSignOutUrl and afterMultiSessionSingleSignOutUrl from the UserButton to UserProfile.

This PR addresses that by positioning those props at the root lever (ClerkProvider or Clerk.load). We considered simply introducing those props to UserProfile, but the naming would not be ideal. We also considered renaming them, but at that point you want the components to always be in sync, so we positioned them at the root.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Also handles in introduction of `afterMultiSessionSingleSignOutUrl` in ClerkProvider
@panteliselef panteliselef self-assigned this Jun 10, 2024
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 10, 2024

🦋 Changeset detected

Latest commit: 29a930c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/shared Patch
@clerk/tanstack-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@panteliselef panteliselef changed the title fix(clerk-js): Deprecate afterSignOutUrl from UserButton. fix(clerk-js): Deprecate afterSignOutUrl from UserButton Jun 10, 2024
Comment on lines +42 to +46
// TODO: Investigate if we need to call `setActive` with {session: null}
if (otherSessions.length === 0) {
return navigateAfterSignOut();
}
await navigateAfterMultiSessionSingleSignOutUrl();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 I wouldn't necessarily expect that this method would need to be aware of multi-session. I understand why it was done this way as part of this PR, but it feels like a better internal abstraction might be to consolidate the multi-session logic into navigateAfterSignOut().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think creating an abstraction here would make our lifer harder, we have useMultisessionActions which needs to know the difference between single session sign out and multisession sign out. We can refactor but i don't see a clear benefit here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benefit would be not having to spread some of this logic across many different methods. That's fine to leave it for now, let's jut keep an eye on these code paths and we can abstract if it feels like multi-session logic is too difficult to manage.

await user.delete();
await navigateAfterSignOut();

// TODO: Investigate if we need to call `setActive` with {session: null}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do this investigation before merge?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was waiting for #3518 to be merged, and i will check again, but simply calling setActive would not refresh the router.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i investigated further, even with #3518 the issue persisted. I've identified this as a FAPI issue, because after user.delete() client_uat comes back with a valid timestamp instead of being 0. This will need a separate ticket to be address and should not be part of this PR

Copy link
Copy Markdown
Member

@brkalow brkalow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment on the changelog, but otherwise looks good.

Comment thread .changeset/selfish-ladybugs-smile.md Outdated
Copy link
Copy Markdown
Member

@anagstef anagstef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants