(params: {
requiredOrgUuid: string
tokenOrgUuid: string
rawAuthTokenSource: null | string
})
| 38 | } |
| 39 | |
| 40 | export function getForceLoginOrgMismatchMessage(params: { |
| 41 | requiredOrgUuid: string |
| 42 | tokenOrgUuid: string |
| 43 | rawAuthTokenSource: null | string |
| 44 | }): string { |
| 45 | const { requiredOrgUuid, tokenOrgUuid, rawAuthTokenSource } = params |
| 46 | |
| 47 | if ( |
| 48 | rawAuthTokenSource && |
| 49 | FORCE_LOGIN_ORG_ENV_TOKEN_SOURCES.has(rawAuthTokenSource) |
| 50 | ) { |
| 51 | return ( |
| 52 | `The ${rawAuthTokenSource} environment variable provides a token for a\n` + |
| 53 | `different organization than required by this machine's managed settings.\n\n` + |
| 54 | `Required organization: ${requiredOrgUuid}\n` + |
| 55 | `Token organization: ${tokenOrgUuid}\n\n` + |
| 56 | `Remove the environment variable or obtain a token for the correct organization.` |
| 57 | ) |
| 58 | } |
| 59 | |
| 60 | return ( |
| 61 | `Your authentication token belongs to organization ${tokenOrgUuid},\n` + |
| 62 | `but this machine requires organization ${requiredOrgUuid}.\n\n` + |
| 63 | `Please log in with the correct organization: code auth login` |
| 64 | ) |
| 65 | } |
| 66 | |
| 67 | export async function validateForceLoginOrgForCurrentSession(): Promise<OrgValidationResult> { |
| 68 | if (process.env.ANTHROPIC_UNIX_SOCKET) { |
no test coverage detected