Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 5x 5x 17x 17x 77x | import { SIGN_IN_ERROR_CODE } from '../constants'
// What each failed sign-in means to the person signing in (design 4.1). Any other code is a retry.
const MESSAGES: Record<string, string> = {
[SIGN_IN_ERROR_CODE.cancelled]: 'Google sign-in was cancelled. Try again when you are ready.',
domain_not_allowed:
'This Google account is not on a company domain Chattra allows. Sign in with your work account.',
network: 'Chattra could not be reached. Check your connection and try again.',
email_not_verified: 'Google has not verified this email address yet.',
account_deactivated: 'This account is deactivated. Ask a workspace admin to turn it back on.',
email_in_use: 'This email already belongs to another Chattra account. Ask a workspace admin.',
session_ended: 'Your session ended. Sign in again.',
not_registered: 'Sign in again to finish setting up your account.',
rate_limited: 'Too many sign-in attempts. Wait a minute and try again.',
broker_unavailable: 'This site does not sign in for previews.',
broker_return_refused: 'This sign-in link does not come from a Chattra preview.',
broker_state_mismatch: 'This sign-in did not start on this page. Sign in again.',
}
const FALLBACK_MESSAGE = 'Sign-in failed. Try again.'
export function getSignInMessage(code: string): string {
// Own keys only: a code such as `constructor` from ?reason= must not reach Object.prototype.
const message = Object.hasOwn(MESSAGES, code) ? MESSAGES[code] : undefined
return message ?? FALLBACK_MESSAGE
}
/** Allowed domains as people type them: `@asnet.com.vn`. */
export function formatDomain(domain: string): string {
return `@${domain}`
}
|