auth-providers.ts 849 B

12345678910111213141516171819202122
  1. import { isCloudMode } from './features'
  2. /**
  3. * Google sign-in for the cloud instance.
  4. *
  5. * Switched on by the pair of env vars and only in cloud mode: a self-hosted
  6. * install would need its own Google project, and the marketing pitch on the
  7. * sign-up page is a cloud page anyway. Distinct from
  8. * GOOGLE_INTEGRATION_CLIENT_ID, which is the calendar connector's client and
  9. * asks for calendar scopes this must never request.
  10. */
  11. export function googleSignInConfig(): { clientId: string; clientSecret: string } | null {
  12. if (!isCloudMode()) return null
  13. const clientId = process.env.GOOGLE_AUTH_CLIENT_ID
  14. const clientSecret = process.env.GOOGLE_AUTH_CLIENT_SECRET
  15. if (!clientId || !clientSecret) return null
  16. return { clientId, clientSecret }
  17. }
  18. export function isGoogleSignInEnabled(): boolean {
  19. return googleSignInConfig() !== null
  20. }