Appearance
isLoginTokenSegment ​
Overview ​
isLoginTokenSegment decides whether one URL path segment is a sign-in token, as in a sign-in link /<brand>/<token>. Route middleware uses it to tell real token-login links apart from ordinary paths, and the Amplitude plugin uses it to strip tokens from analytics.
Added in commit df54f0c on the security audit branch (PR #144). It replaced several inline length >= 32 && /^[a-fA-F0-9]+$/ checks. The new signed token format comes from the backend; see Backend API — Sign-in Tokens and Re-authentication (Nov 2026).
File Information ​
- Path:
app/utils/isLoginTokenSegment.ts - Export:
isLoginTokenSegment(value?: string | null): boolean - Auto-import: yes (
utils/**is inimports.dirs)
Rules ​
Empty, null or undefined returns false. Otherwise the value must fully match one of:
| Constant | Pattern (case-insensitive) | Shape |
|---|---|---|
SIGNED_LOGIN_TOKEN | ^\d+\.\d+\.\d+\.[a-f0-9]{64}$ | three dot-separated integers, a dot, then 64 hex characters |
LEGACY_HEX_LOGIN_TOKEN | ^[a-f0-9]{32,}$ | 32 or more hex characters |
| Value | Result |
|---|---|
12.34.1767225600. followed by 64 hex characters | true (signed) |
0123456789abcdef0123456789abcdef (32 hex) | true (legacy) |
folders, search, login | false |
0123456789abcdef (16 hex) | false |
12.34.56.abc | false (hash too short) |
Callers ​
| File | Use |
|---|---|
app/middleware/auth.global.ts | isTokenLoginPath: a two-segment path whose second segment is a token is public (token-login) |
app/middleware/check-url.ts | (1) the asset-request skip ignores paths containing . unless a segment is a token, because signed tokens contain dots; (2) clears the session when params.token or the first path segment is a token; (3) on a custom domain, a token in the brand position triggers loginWithToken before redirecting to the workspace slug |
app/middleware/public-portal-home.ts | returns early when the brand_name param is a token, so public-portal auto-login does not run on a token link |
app/pages/[brand_name]/[...slug].vue | a single slug segment that is a token redirects to the named route brand_name-token-index |
app/plugins/amplitude.client.ts | redactLoginTokens replaces every token-shaped segment in event and user properties with [redacted] |
The token page app/pages/[brand_name]/[token]/index.vue does not use this helper. Its definePageMeta validate accepts only the signed shape (/^\d+\.\d+\.\d+\.[a-f0-9]{64}$/i, since commit fa8d743), so a legacy 32-hex segment no longer matches that route directly; it reaches [...slug].vue, which forwards it to brand_name-token-index by name.