mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-21 17:41:25 -08:00
Fix preserve add account param (#992)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Fixes the register link in the login page going back to the client if the user is trying to add a new account by adding the `addAccount=1` query param in the register page url #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
This commit is contained in:
3 files changed
+19
-3
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix registration not working when accessed from add account button
|
||||
@@ -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">
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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 (
|
||||
<Box direction="Column" gap="500">
|
||||
<Text size="H2" priority="400">
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user