From fbec0322efa4fec47f695cfacbf4de1b796e49f1 Mon Sep 17 00:00:00 2001 From: Void Date: Tue, 10 Nov 2026 23:41:29 +0000 Subject: [PATCH] auth: register failures in plain words; /register goes to the account service when the switch is on The previous commit carried only the fallback split. This one carries the rest of Libby's two blockers and Heimdall's decision: - config.json keeps only the registration block over dev's; clientDefaultServer is dev's again (the gamecult.org default is #86). - registerErrorTrouble maps a register error code to registerTroubleMessage (new troubles: password-weak, password-short, unknown); PasswordRegisterForm shows those, never the server's text. - RegisterRoute: switch on, /register offers the account service link and redirects there; switch off, the in-client form. - Tests: registerErrors.test.ts (code to words, no Matrix code leaks), RegisterRoute.test.tsx (on, off, unusable url). Co-Authored-By: Claude Sonnet 5.5 --- config.json | 5 +++ src/app/hooks/useClientConfig.ts | 2 +- src/app/pages/auth/authMessages.ts | 15 ++++++- src/app/pages/auth/authRoutes.tsx | 4 +- .../auth/register/PasswordRegisterForm.tsx | 41 ++++++++----------- .../auth/register/RegisterRoute.test.tsx | 37 +++++++++++++++++ src/app/pages/auth/register/RegisterRoute.tsx | 26 ++++++++++++ .../auth/register/registerErrors.test.ts | 39 ++++++++++++++++++ src/app/pages/auth/register/registerUtil.ts | 22 ++++++++++ 9 files changed, 162 insertions(+), 29 deletions(-) create mode 100644 src/app/pages/auth/register/RegisterRoute.test.tsx create mode 100644 src/app/pages/auth/register/RegisterRoute.tsx create mode 100644 src/app/pages/auth/register/registerErrors.test.ts diff --git a/config.json b/config.json index ed1bca6b..772b61c3 100644 --- a/config.json +++ b/config.json @@ -24,5 +24,10 @@ "dings": { "enabled": false + }, + + "registration": { + "enabled": false, + "url": "" } } diff --git a/src/app/hooks/useClientConfig.ts b/src/app/hooks/useClientConfig.ts index cc293eb1..adc4a64b 100644 --- a/src/app/hooks/useClientConfig.ts +++ b/src/app/hooks/useClientConfig.ts @@ -50,7 +50,7 @@ export function useClientConfig(): ClientConfig { } export const clientDefaultServer = (clientConfig: ClientConfig): string => - clientConfig.homeserverList?.[clientConfig.defaultHomeserver ?? 0] ?? 'gamecult.org'; + clientConfig.homeserverList?.[clientConfig.defaultHomeserver ?? 0] ?? 'matrix.org'; export const clientAllowedServer = (clientConfig: ClientConfig, server: string): boolean => { const { homeserverList, allowCustomHomeservers } = clientConfig; diff --git a/src/app/pages/auth/authMessages.ts b/src/app/pages/auth/authMessages.ts index 3cc858fe..4d9575a5 100644 --- a/src/app/pages/auth/authMessages.ts +++ b/src/app/pages/auth/authMessages.ts @@ -57,7 +57,14 @@ export const serverTroubleMessage = ( export const noSignInMethodMessage = (server: string): string => `${server} does not offer a way to sign in that this app can use. Pick another server from the Homeserver list, or tell whoever runs ${server}.`; -export type RegisterTrouble = 'closed' | 'rate-limited' | 'invalid' | 'unsupported'; +export type RegisterTrouble = + | 'closed' + | 'rate-limited' + | 'invalid' + | 'unsupported' + | 'password-weak' + | 'password-short' + | 'unknown'; export const registerTroubleMessage = (trouble: RegisterTrouble, server: string): string => { switch (trouble) { @@ -67,6 +74,12 @@ export const registerTroubleMessage = (trouble: RegisterTrouble, server: string) return 'Too many tries in a short time. Wait a minute, then try again.'; case 'invalid': return `${server} did not accept the request to make an account. Reload the page and try again; if it keeps failing, tell whoever invited you.`; + case 'password-weak': + return 'That password is too easy to guess. Pick a longer one, with more than one kind of character.'; + case 'password-short': + return 'That password is too short. Pick a longer one.'; + case 'unknown': + return `Something went wrong making the account on ${server}. Try again in a minute; if it keeps failing, tell whoever invited you.`; case 'unsupported': default: return `${server} asks for something this app cannot do when making an account. Tell whoever invited you.`; diff --git a/src/app/pages/auth/authRoutes.tsx b/src/app/pages/auth/authRoutes.tsx index c6fcd2c1..c5ad101f 100644 --- a/src/app/pages/auth/authRoutes.tsx +++ b/src/app/pages/auth/authRoutes.tsx @@ -6,7 +6,7 @@ import { LOGIN_PATH, REGISTER_PATH, RESET_PASSWORD_PATH, SIGNED_UP_PATH } from ' import { getHomePath } from '../pathUtils'; import { AuthLayout } from './AuthLayout'; import { Login } from './login'; -import { Register } from './register'; +import { RegisterRoute } from './register/RegisterRoute'; import { ResetPassword } from './reset-password'; import { SignedUp } from './SignedUp'; @@ -24,7 +24,7 @@ export const authRoutes = () => ( } > } /> - } /> + } /> } /> createClient({ baseUrl }), [baseUrl]); @@ -207,6 +216,9 @@ export function PasswordRegisterForm({ const registerError = registerState.status === AsyncStatus.Error ? registerState.error : undefined; + // The password troubles show under the password field; the rest is the form's. + const registerTrouble = registerError && registerErrorTrouble(registerError.errcode); + const formTrouble = registerTrouble?.startsWith('password-') ? undefined : registerTrouble; useRegisterComplete(customRegisterResp); const handleSubmit: ChangeEventHandler = (evt) => { @@ -298,20 +310,10 @@ export function PasswordRegisterForm({ required /> {registerError?.errcode === RegisterError.PasswordWeak && ( - + )} {registerError?.errcode === RegisterError.PasswordShort && ( - + )} @@ -378,18 +380,7 @@ export function PasswordRegisterForm({ )} - {registerError?.errcode === RegisterError.RateLimited && ( - - )} - {registerError?.errcode === RegisterError.Forbidden && ( - - )} - {registerError?.errcode === RegisterError.InvalidRequest && ( - - )} - {registerError?.errcode === RegisterError.Unknown && ( - - )} + {formTrouble && } setTrainingAck((ack) => !ack)} />