Skip to content

(Proof of Concept) Following redirect url after creating an account from /sign-in/choose #6390

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { SignedInSessionResource, UserButtonProps, UserResource } from '@cl
import { useCardState } from '@/ui/elements/contexts';
import { sleep } from '@/ui/utils/sleep';

import { buildURL } from '../../../utils';
import { windowNavigate } from '../../../utils/windowNavigate';
import { useMultipleSessions } from '../../hooks/useMultipleSessions';
import { useRouter } from '../../router';
Expand Down Expand Up @@ -79,7 +80,25 @@ export const useMultisessionActions = (opts: UseMultisessionActionsParams) => {
};

const handleAddAccountClicked = () => {
windowNavigate(opts.signInUrl || window.location.href);
const signInUrl = opts.signInUrl || window.location.href;

// If we have an afterSwitchSessionUrl, append it as a query parameter
if (opts.afterSwitchSessionUrl) {
const searchParams = new URLSearchParams();
searchParams.set('redirect_url', opts.afterSwitchSessionUrl);

const url = buildURL(
{
base: signInUrl,
searchParams,
},
{ stringify: true },
);
windowNavigate(url);
} else {
windowNavigate(signInUrl);
}

return sleep(2000);
};

Expand Down
Loading