From 137fb5a96c6c9cfe82bc2d07d5211838cae7f87b Mon Sep 17 00:00:00 2001 From: Void Date: Tue, 10 Nov 2026 17:23:51 +0000 Subject: [PATCH] auth: sign-up return page renders; gamecult.org is the default homeserver /signed-up/ sat inside AuthLayout, which discovers a homeserver and sends paths it does not know to sign in, so it never rendered. The signed-out routes move to authRoutes.tsx with the return page beside the layout (its own card, no discovery); a test matches the real route table and renders the page. Drop the visible notice version from the entry (it stays in registrationEntry's data and tests) and the unused getSignedUpPath. clientDefaultServer falls back to gamecult.org, and the repo config.json lists it first and defaults to it; a config that names its own list (the production pin) is unaffected. Co-Authored-By: Claude Sonnet 5.5 --- config.json | 11 ++++-- src/app/hooks/useClientConfig.test.ts | 20 +++++++++++ src/app/hooks/useClientConfig.ts | 2 +- src/app/pages/Router.tsx | 29 ++------------- src/app/pages/auth/RegisterEntry.tsx | 2 +- src/app/pages/auth/SignedUp.tsx | 52 +++++++++++++++++++++------ src/app/pages/auth/authRoutes.tsx | 40 +++++++++++++++++++++ src/app/pages/pathUtils.ts | 3 -- src/app/pages/signedUpRoute.test.tsx | 51 ++++++++++++++++++++++++++ 9 files changed, 166 insertions(+), 44 deletions(-) create mode 100644 src/app/hooks/useClientConfig.test.ts create mode 100644 src/app/pages/auth/authRoutes.tsx create mode 100644 src/app/pages/signedUpRoute.test.tsx diff --git a/config.json b/config.json index 82bcf80d..ff3c52bb 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,13 @@ { - "defaultHomeserver": 1, - "homeserverList": ["converser.eu", "matrix.org", "mozilla.org", "unredacted.org", "xmr.se"], + "defaultHomeserver": 0, + "homeserverList": [ + "gamecult.org", + "converser.eu", + "matrix.org", + "mozilla.org", + "unredacted.org", + "xmr.se" + ], "allowCustomHomeservers": true, "featuredCommunities": { "openAsDefault": false, diff --git a/src/app/hooks/useClientConfig.test.ts b/src/app/hooks/useClientConfig.test.ts new file mode 100644 index 00000000..a2004d2f --- /dev/null +++ b/src/app/hooks/useClientConfig.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest'; +import { clientDefaultServer } from './useClientConfig'; +import config from '../../../config.json'; + +describe('default homeserver', () => { + it('is gamecult.org when the config names none', () => { + expect(clientDefaultServer({})).toBe('gamecult.org'); + expect(clientDefaultServer({ homeserverList: [] })).toBe('gamecult.org'); + }); + + it('is the listed server the config points at', () => { + expect( + clientDefaultServer({ homeserverList: ['chat.gamecult.org'], defaultHomeserver: 0 }) + ).toBe('chat.gamecult.org'); + }); + + it('is gamecult.org in the repo config.json too', () => { + expect(clientDefaultServer(config)).toBe('gamecult.org'); + }); +}); diff --git a/src/app/hooks/useClientConfig.ts b/src/app/hooks/useClientConfig.ts index 1b5f084a..fb6f3257 100644 --- a/src/app/hooks/useClientConfig.ts +++ b/src/app/hooks/useClientConfig.ts @@ -46,7 +46,7 @@ export function useClientConfig(): ClientConfig { } export const clientDefaultServer = (clientConfig: ClientConfig): string => - clientConfig.homeserverList?.[clientConfig.defaultHomeserver ?? 0] ?? 'matrix.org'; + clientConfig.homeserverList?.[clientConfig.defaultHomeserver ?? 0] ?? 'gamecult.org'; export const clientAllowedServer = (clientConfig: ClientConfig, server: string): boolean => { const { homeserverList, allowCustomHomeservers } = clientConfig; diff --git a/src/app/pages/Router.tsx b/src/app/pages/Router.tsx index fe6b9cd4..47455005 100644 --- a/src/app/pages/Router.tsx +++ b/src/app/pages/Router.tsx @@ -9,16 +9,12 @@ import { } from 'react-router-dom'; import { ClientConfig } from '../hooks/useClientConfig'; -import { AuthLayout, Login, Register, ResetPassword, SignedUp } from './auth'; +import { authRoutes } from './auth/authRoutes'; import { DIRECT_PATH, EXPLORE_PATH, HOME_PATH, - LOGIN_PATH, INBOX_PATH, - REGISTER_PATH, - SIGNED_UP_PATH, - RESET_PASSWORD_PATH, SPACE_PATH, _CREATE_PATH, _FEATURED_PATH, @@ -56,7 +52,7 @@ import { ScreenSize } from '../hooks/useScreenSize'; import { MobileFriendlyPageNav } from './MobileFriendly'; import { ClientInitStorageAtom } from './client/ClientInitStorageAtom'; import { ClientNonUIFeatures } from './client/ClientNonUIFeatures'; -import { AuthRouteThemeManager, UnAuthRouteThemeManager } from './ThemeManager'; +import { AuthRouteThemeManager } from './ThemeManager'; import { ReceiveSelfDeviceVerification } from '../components/DeviceVerification'; import { AutoRestoreBackupOnVerification } from '../components/BackupRestore'; import { RoomSettingsRenderer } from '../features/room-settings'; @@ -87,26 +83,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) return redirect(getLoginPath()); }} /> - { - if (getFallbackSession()) { - return redirect(getHomePath()); - } - - return null; - }} - element={ - <> - - - - } - > - } /> - } /> - } /> - } /> - + {authRoutes()} { diff --git a/src/app/pages/auth/RegisterEntry.tsx b/src/app/pages/auth/RegisterEntry.tsx index d60e19a6..e594c83c 100644 --- a/src/app/pages/auth/RegisterEntry.tsx +++ b/src/app/pages/auth/RegisterEntry.tsx @@ -15,7 +15,7 @@ export function RegisterEntry() { Do not have an account? Register - {entry.notice} (notice version {entry.noticeVersion}) + {entry.notice} ); diff --git a/src/app/pages/auth/SignedUp.tsx b/src/app/pages/auth/SignedUp.tsx index 70ceff06..303e0d72 100644 --- a/src/app/pages/auth/SignedUp.tsx +++ b/src/app/pages/auth/SignedUp.tsx @@ -1,24 +1,54 @@ -import { Box, Text } from 'folds'; +import { Box, Header, Scroll, Text } from 'folds'; +import classNames from 'classnames'; import React from 'react'; import { Link, Navigate } from 'react-router-dom'; import { useClientConfig } from '../../hooks/useClientConfig'; import { getLoginPath } from '../pathUtils'; import { registrationEntry } from './registrationEntry'; +import { AuthFooter } from './AuthFooter'; +import * as css from './styles.css'; +import * as PatternsCss from '../../styles/Patterns.css'; +import RatatoskrSVG from '../../../../public/res/svg/ratatoskr.svg'; +import { LogoMark } from '../../components/logo/logoMark.css'; // Where the account service sends a newcomer back. It promises nothing about mail or timing: -// the sign-up page said what happens next, and this page points back to it. +// the sign-up page said what happens next, and this page points back to it. It has its own card +// because AuthLayout looks up a homeserver first and sends paths it does not know to sign in. export function SignedUp() { const config = useClientConfig(); if (!registrationEntry(config)) return ; return ( - - - You signed up - - Follow the steps from the sign-up page to finish. Then sign in here. - - Sign in - - + + + +
+ + Ratatoskr logo + Ratatoskr + +
+ + + You signed up + + Follow the steps from the sign-up page to finish. Then sign in here. + + Sign in + + +
+ +
+
); } diff --git a/src/app/pages/auth/authRoutes.tsx b/src/app/pages/auth/authRoutes.tsx new file mode 100644 index 00000000..c6fcd2c1 --- /dev/null +++ b/src/app/pages/auth/authRoutes.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { Route, redirect } from 'react-router-dom'; +import { getFallbackSession } from '../../state/sessions'; +import { UnAuthRouteThemeManager } from '../ThemeManager'; +import { LOGIN_PATH, REGISTER_PATH, RESET_PASSWORD_PATH, SIGNED_UP_PATH } from '../paths'; +import { getHomePath } from '../pathUtils'; +import { AuthLayout } from './AuthLayout'; +import { Login } from './login'; +import { Register } from './register'; +import { ResetPassword } from './reset-password'; +import { SignedUp } from './SignedUp'; + +// The routes a signed-out visitor sees. The sign-up return page sits beside the layout, not in +// it: the layout looks up a homeserver and sends any path it does not know to sign in. +export const authRoutes = () => ( + <> + (getFallbackSession() ? redirect(getHomePath()) : null)} + element={ + <> + + + + } + > + } /> + } /> + } /> + + + + + + } + /> + +); diff --git a/src/app/pages/pathUtils.ts b/src/app/pages/pathUtils.ts index c5346f20..817d21d1 100644 --- a/src/app/pages/pathUtils.ts +++ b/src/app/pages/pathUtils.ts @@ -16,7 +16,6 @@ import { INBOX_NOTIFICATIONS_PATH, INBOX_PATH, REGISTER_PATH, - SIGNED_UP_PATH, RESET_PASSWORD_PATH, ROOT_PATH, SPACE_LOBBY_PATH, @@ -83,8 +82,6 @@ export const getRegisterPath = (server?: string): string => { return generatePath(REGISTER_PATH, params); }; -export const getSignedUpPath = (): string => SIGNED_UP_PATH; - export const getResetPasswordPath = (server?: string): string => { const params = server ? { server: encodeURIComponent(server) } : undefined; return generatePath(RESET_PASSWORD_PATH, params); diff --git a/src/app/pages/signedUpRoute.test.tsx b/src/app/pages/signedUpRoute.test.tsx new file mode 100644 index 00000000..e1f69d31 --- /dev/null +++ b/src/app/pages/signedUpRoute.test.tsx @@ -0,0 +1,51 @@ +import React from 'react'; +import { beforeAll, describe, expect, it, vi } from 'vitest'; +import { renderToString } from 'react-dom/server'; +import { Route, createRoutesFromElements } from 'react-router-dom'; +import { StaticRouter, createStaticHandler } from 'react-router-dom/server'; +import { ClientConfigProvider } from '../hooks/useClientConfig'; +import type { ClientConfig } from '../hooks/useClientConfig'; +import { SIGNED_UP_PATH } from './paths'; + +const config: ClientConfig = { registration: { enabled: true, url: 'https://accounts.example/' } }; + +// The routes read localStorage when imported (settings atoms); the node environment has none. +let authRoutes: typeof import('./auth/authRoutes').authRoutes; +let SignedUp: typeof import('./auth').SignedUp; +beforeAll(async () => { + vi.stubGlobal('localStorage', { + getItem: () => null, + setItem: () => undefined, + removeItem: () => undefined, + }); + ({ authRoutes } = await import('./auth/authRoutes')); + ({ SignedUp } = await import('./auth')); +}, 120_000); + +const matchPath = async (path: string) => { + const { query } = createStaticHandler(createRoutesFromElements({authRoutes()})); + const context = await query(new Request(`http://localhost${path}`)); + if (context instanceof Response) { + throw new Error(`redirected to ${context.headers.get('Location')}`); + } + return context.matches; +}; + +describe('the sign-up return page in the real route table', () => { + it('is its own route, outside AuthLayout (which would send it to sign in)', async () => { + const matches = await matchPath(SIGNED_UP_PATH); + // the pathless root, then the page itself: no layout route in between + expect(matches?.map((m) => m.route.path)).toEqual([undefined, SIGNED_UP_PATH]); + }); + + it('renders its words, not the sign-in form, when the switch is on', () => { + const html = renderToString( + + + + + + ); + expect(html).toContain('Follow the steps from the sign-up page'); + }); +});