fine
This commit is contained in:
parent
6df2812a4e
commit
9e4e65fa2a
35 changed files with 1172 additions and 70 deletions
|
|
@ -8,7 +8,7 @@ import type { TFunction } from 'i18next';
|
|||
*/
|
||||
export type AuthErrorAction = 'switchToLogin' | null;
|
||||
|
||||
export type AuthContext = 'login' | 'register' | 'oauth' | 'reset';
|
||||
export type AuthContext = 'login' | 'register' | 'oauth' | 'reset' | 'confirmReset';
|
||||
|
||||
export interface ResolvedAuthError {
|
||||
/** User-facing message (already resolved to a string). */
|
||||
|
|
@ -75,5 +75,17 @@ export function resolveAuthError(
|
|||
return { message: t('auth.oauthFailed'), action: null };
|
||||
}
|
||||
|
||||
// Submitting a new password from the emailed reset link. A weak password comes
|
||||
// back as a field error; anything else (bad/expired/used token) is a dead link.
|
||||
if (context === 'confirmReset') {
|
||||
if (fieldCode(e, 'password')) {
|
||||
return { message: t('auth.errorPasswordWeak'), action: null };
|
||||
}
|
||||
if (status === 400 || status === 404) {
|
||||
return { message: t('auth.resetInvalidLink'), action: null };
|
||||
}
|
||||
return { message: t('auth.passwordResetFailed'), action: null };
|
||||
}
|
||||
|
||||
return { message: t('auth.passwordResetFailed'), action: null };
|
||||
}
|
||||
|
|
|
|||
22
frontend/src/lib/postcode.ts
Normal file
22
frontend/src/lib/postcode.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Postcode-component helpers, mirroring the server's `postcode_outcode` /
|
||||
* `postcode_sector` (server-rs/src/utils.rs) so labels match the aggregations.
|
||||
*/
|
||||
|
||||
/** Outward code of a postcode: the part before the space. "E14 2DG" -> "E14". */
|
||||
export function postcodeOutcode(postcode: string): string | null {
|
||||
const trimmed = postcode.trim().toUpperCase();
|
||||
const space = trimmed.indexOf(' ');
|
||||
return space > 0 ? trimmed.slice(0, space) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Postcode sector: the outward code, the space, and the first character of the
|
||||
* inward code. "E14 2DG" -> "E14 2".
|
||||
*/
|
||||
export function postcodeSector(postcode: string): string | null {
|
||||
const trimmed = postcode.trim().toUpperCase();
|
||||
const space = trimmed.indexOf(' ');
|
||||
if (space <= 0 || space + 1 >= trimmed.length) return null;
|
||||
return trimmed.slice(0, space + 2);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue