diff --git a/.changeset/fix-preserve-add-account-param.md b/.changeset/fix-preserve-add-account-param.md new file mode 100644 index 000000000..1b78177c7 --- /dev/null +++ b/.changeset/fix-preserve-add-account-param.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix registration not working when accessed from add account button diff --git a/src/app/pages/auth/login/Login.tsx b/src/app/pages/auth/login/Login.tsx index 7f53af090..2aa6fc8a5 100644 --- a/src/app/pages/auth/login/Login.tsx +++ b/src/app/pages/auth/login/Login.tsx @@ -55,6 +55,12 @@ export function Login() { const parsedFlows = useParsedLoginFlows(loginFlows.flows); + const isAddingAccount = searchParams.get('addAccount') === '1'; + + const registerUrl = isAddingAccount + ? withSearchParam(getRegisterPath(server), { addAccount: '1' }) + : getRegisterPath(server); + return ( @@ -93,7 +99,7 @@ export function Login() { )} - Do not have an account? Register + Do not have an account? Register ); diff --git a/src/app/pages/auth/register/Register.tsx b/src/app/pages/auth/register/Register.tsx index 73497255e..df9aa123e 100644 --- a/src/app/pages/auth/register/Register.tsx +++ b/src/app/pages/auth/register/Register.tsx @@ -6,7 +6,7 @@ import { useAuthServer } from '$hooks/useAuthServer'; import { RegisterFlowStatus, useAuthFlows } from '$hooks/useAuthFlows'; import { useParsedLoginFlows } from '$hooks/useParsedLoginFlows'; import { SupportedUIAFlowsLoader } from '$components/SupportedUIAFlowsLoader'; -import { getLoginPath } from '$pages/pathUtils'; +import { getLoginPath, withSearchParam } from '$pages/pathUtils'; import { usePathWithOrigin } from '$hooks/usePathWithOrigin'; import type { RegisterPathSearchParams } from '$pages/paths'; import { SSOLogin } from '$pages/auth/SSOLogin'; @@ -33,6 +33,11 @@ export function Register() { // redirect to /login because only that path handle m.login.token const ssoRedirectUrl = usePathWithOrigin(getLoginPath(server)); + const isAddingAccount = searchParams.get('addAccount') === '1'; + const loginUrl = isAddingAccount + ? withSearchParam(getLoginPath(server), { addAccount: '1' }) + : getLoginPath(server); + return ( @@ -91,7 +96,7 @@ export function Register() { )} - Already have an account? Login + Already have an account? Login );