Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/fix-preserve-add-account-param.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

Fix registration not working when accessed from add account button
8 changes: 7 additions & 1 deletion src/app/pages/auth/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Box direction="Column" gap="500">
<Text size="H2" priority="400">
Expand Down Expand Up @@ -93,7 +99,7 @@ export function Login() {
</>
)}
<Text align="Center">
Do not have an account? <Link to={getRegisterPath(server)}>Register</Link>
Do not have an account? <Link to={registerUrl}>Register</Link>
</Text>
</Box>
);
Expand Down
9 changes: 7 additions & 2 deletions src/app/pages/auth/register/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 (
<Box direction="Column" gap="500">
<Text size="H2" priority="400">
Expand Down Expand Up @@ -91,7 +96,7 @@ export function Register() {
</>
)}
<Text align="Center">
Already have an account? <Link to={getLoginPath(server)}>Login</Link>
Already have an account? <Link to={loginUrl}>Login</Link>
</Text>
</Box>
);
Expand Down
Loading