mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat: add a shared base for integrations that connect an account through OAuth * fix: keep OAuth account scopes current and bound provider answers * fix: share parent registration between form APIs * fix: preserve refreshed OAuth tokens when actions fail * refactor: use absolute imports for parent OAuth modules * refactor: decouple OAuth cleanup from application publication models * refactor: use common import hooks for OAuth connections * fix: keep OAuth account integrations out of the workspace --------- Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
import { OAUTH_ERROR_CODE } from '@baserow/modules/integrations/oauthAccount/constants'
|
|
|
|
const MESSAGES = {
|
|
[OAUTH_ERROR_CODE.NOT_CONFIGURED]: 'oauthAccountErrors.notConfigured',
|
|
[OAUTH_ERROR_CODE.STATE_INVALID]: 'oauthAccountErrors.stateInvalid',
|
|
[OAUTH_ERROR_CODE.SIGN_IN_CANCELLED]: 'oauthAccountErrors.cancelled',
|
|
[OAUTH_ERROR_CODE.ADMIN_CONSENT_REQUIRED]:
|
|
'oauthAccountErrors.adminConsentRequired',
|
|
[OAUTH_ERROR_CODE.TENANT_NOT_ALLOWED]: 'oauthAccountErrors.tenantNotAllowed',
|
|
[OAUTH_ERROR_CODE.CLIENT_REJECTED]: 'oauthAccountErrors.clientRejected',
|
|
[OAUTH_ERROR_CODE.ACCOUNT_MISMATCH]: 'oauthAccountErrors.accountMismatch',
|
|
[OAUTH_ERROR_CODE.SERVICE_TYPE_NOT_ALLOWED]:
|
|
'oauthAccountErrors.serviceTypeNotAllowed',
|
|
[OAUTH_ERROR_CODE.POPUP_BLOCKED]: 'oauthAccountErrors.popupBlocked',
|
|
}
|
|
|
|
/**
|
|
* What to tell the person when a sign-in failed.
|
|
*
|
|
* @param {Function} t The translate function.
|
|
* @param {string|null} code The API error code, null when none came back.
|
|
* @param {string} provider The provider's name, e.g. `Microsoft`.
|
|
* @returns {string}
|
|
*/
|
|
export function oauthErrorMessage(t, code, provider) {
|
|
return t(MESSAGES[code] || 'oauthAccountErrors.failed', { provider })
|
|
}
|