build(docker): 🧱 Improve runtime environment
This commit is contained in:
@ -1,13 +1,7 @@
|
||||
# Don't edit this file
|
||||
NEXT_PUBLIC_VIEWER_URL=DOCKER_PUBLIC_VIEWER_URL
|
||||
NEXT_PUBLIC_VIEWER_URL=DOCKER_NEXT_PUBLIC_VIEWER_URL
|
||||
NEXT_PUBLIC_SMTP_FROM=DOCKER_NEXT_PUBLIC_SMTP_FROM
|
||||
NEXT_PUBLIC_SMTP_AUTH_DISABLED=DOCKER_NEXT_PUBLIC_SMTP_AUTH_DISABLED
|
||||
NEXT_PUBLIC_GOOGLE_CLIENT_ID=DOCKER_NEXT_PUBLIC_GOOGLE_CLIENT_ID
|
||||
NEXT_PUBLIC_GOOGLE_API_KEY=DOCKER_NEXT_PUBLIC_GOOGLE_API_KEY
|
||||
NEXT_PUBLIC_GITHUB_CLIENT_ID=DOCKER_NEXT_PUBLIC_GITHUB_CLIENT_ID
|
||||
NEXT_PUBLIC_GITLAB_CLIENT_ID=DOCKER_NEXT_PUBLIC_GITLAB_CLIENT_ID
|
||||
NEXT_PUBLIC_GITLAB_NAME=DOCKER_NEXT_PUBLIC_GITLAB_NAME
|
||||
NEXT_PUBLIC_FACEBOOK_CLIENT_ID=DOCKER_NEXT_PUBLIC_FACEBOOK_CLIENT_ID
|
||||
NEXT_PUBLIC_GIPHY_API_KEY=DOCKER_NEXT_PUBLIC_GIPHY_API_KEY
|
||||
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=DOCKER_NEXT_PUBLIC_STRIPE_PUBLIC_KEY
|
||||
NEXT_PUBLIC_SENTRY_DSN=DOCKER_NEXT_PUBLIC_SENTRY_DSN
|
||||
|
@ -3,7 +3,7 @@ ENCRYPTION_SECRET=SgVkYp2s5v8y/B?E(H+MbQeThWmZq4t6 #256-bits secret (can be gene
|
||||
NEXTAUTH_URL=http://localhost:3000
|
||||
NEXT_PUBLIC_VIEWER_URL=http://localhost:3001
|
||||
|
||||
NEXT_PUBLIC_GITHUB_CLIENT_ID=534b549dd17709a743a2
|
||||
GITHUB_CLIENT_ID=534b549dd17709a743a2
|
||||
GITHUB_CLIENT_SECRET=7adb03507504fb1a54422f6c3c697277cfd000a9
|
||||
|
||||
S3_ACCESS_KEY=minio
|
||||
@ -13,8 +13,5 @@ S3_PORT=9000
|
||||
S3_ENDPOINT=localhost
|
||||
S3_SSL=false
|
||||
|
||||
# Used for Google Fonts dropdown
|
||||
NEXT_PUBLIC_GOOGLE_API_KEY=AIzaSyAWuhjY55xbR-J9Yb1nkAQ13r6A7GDCx2k
|
||||
|
||||
# For more configuration options check out:
|
||||
https://docs.typebot.io/self-hosting/configuration
|
||||
# https://docs.typebot.io/self-hosting/configuration
|
@ -1,6 +0,0 @@
|
||||
DATABASE_URL=postgresql://postgres:typebot@db:5432/typebot
|
||||
NEXT_PUBLIC_VIEWER_URL=http://localhost:8081
|
||||
ENCRYPTION_SECRET=SgVkYp2s5v8y/B?E(H+MbQeThWmZq4t6
|
||||
ADMIN_EMAIL=contact@baptiste-arnaud.fr
|
||||
NEXTAUTH_URL=http://localhost:8080
|
||||
NEXTAUTH_URL_INTERNAL=http://host.docker.internal:8080
|
@ -9,20 +9,18 @@ import {
|
||||
} from '@chakra-ui/react'
|
||||
import React, { ChangeEvent, FormEvent, useEffect } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { signIn, useSession } from 'next-auth/react'
|
||||
import {
|
||||
ClientSafeProvider,
|
||||
getProviders,
|
||||
LiteralUnion,
|
||||
signIn,
|
||||
useSession,
|
||||
} from 'next-auth/react'
|
||||
import { DividerWithText } from './DividerWithText'
|
||||
import { SocialLoginButtons } from './SocialLoginButtons'
|
||||
import { useRouter } from 'next/router'
|
||||
import { NextChakraLink } from 'components/nextChakra/NextChakraLink'
|
||||
import { isEmpty, isNotEmpty } from 'utils'
|
||||
|
||||
const hasNoAuthProvider =
|
||||
(isEmpty(process.env.NEXT_PUBLIC_SMTP_FROM) ||
|
||||
process.env.NEXT_PUBLIC_SMTP_AUTH_DISABLED === 'true') &&
|
||||
isEmpty(process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID) &&
|
||||
isEmpty(process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID) &&
|
||||
isEmpty(process.env.NEXT_PUBLIC_FACEBOOK_CLIENT_ID) &&
|
||||
isEmpty(process.env.NEXT_PUBLIC_GITLAB_CLIENT_ID)
|
||||
import { BuiltInProviderType } from 'next-auth/providers'
|
||||
|
||||
type Props = {
|
||||
defaultEmail?: string
|
||||
@ -33,14 +31,28 @@ export const SignInForm = ({
|
||||
const router = useRouter()
|
||||
const { status } = useSession()
|
||||
const [authLoading, setAuthLoading] = useState(false)
|
||||
const [isLoadingProviders, setIsLoadingProviders] = useState(true)
|
||||
|
||||
const [emailValue, setEmailValue] = useState(defaultEmail ?? '')
|
||||
const toast = useToast({
|
||||
position: 'top-right',
|
||||
})
|
||||
const [providers, setProviders] =
|
||||
useState<
|
||||
Record<LiteralUnion<BuiltInProviderType, string>, ClientSafeProvider>
|
||||
>()
|
||||
|
||||
const hasNoAuthProvider =
|
||||
!isLoadingProviders && Object.keys(providers ?? {}).length === 0
|
||||
|
||||
useEffect(() => {
|
||||
if (status === 'authenticated')
|
||||
router.replace({ pathname: '/typebots', query: router.query })
|
||||
;(async () => {
|
||||
const providers = await getProviders()
|
||||
setProviders(providers ?? undefined)
|
||||
setIsLoadingProviders(false)
|
||||
})()
|
||||
}, [status, router])
|
||||
|
||||
const handleEmailChange = (e: ChangeEvent<HTMLInputElement>) =>
|
||||
@ -77,32 +89,31 @@ export const SignInForm = ({
|
||||
)
|
||||
return (
|
||||
<Stack spacing="4" w="330px">
|
||||
<SocialLoginButtons />
|
||||
{isNotEmpty(process.env.NEXT_PUBLIC_SMTP_FROM) &&
|
||||
process.env.NEXT_PUBLIC_SMTP_AUTH_DISABLED !== 'true' && (
|
||||
<>
|
||||
<DividerWithText mt="6">Or with your email</DividerWithText>
|
||||
<HStack as="form" onSubmit={handleEmailSubmit}>
|
||||
<Input
|
||||
name="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
placeholder="email@company.com"
|
||||
required
|
||||
value={emailValue}
|
||||
onChange={handleEmailChange}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
isLoading={
|
||||
['loading', 'authenticated'].includes(status) || authLoading
|
||||
}
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
</HStack>
|
||||
</>
|
||||
)}
|
||||
<SocialLoginButtons providers={providers} />
|
||||
{providers?.email && (
|
||||
<>
|
||||
<DividerWithText mt="6">Or with your email</DividerWithText>
|
||||
<HStack as="form" onSubmit={handleEmailSubmit}>
|
||||
<Input
|
||||
name="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
placeholder="email@company.com"
|
||||
required
|
||||
value={emailValue}
|
||||
onChange={handleEmailChange}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
isLoading={
|
||||
['loading', 'authenticated'].includes(status) || authLoading
|
||||
}
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
</HStack>
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
|
@ -1,13 +1,24 @@
|
||||
import { Stack, Button } from '@chakra-ui/react'
|
||||
import { GithubIcon } from 'assets/icons'
|
||||
import { signIn, useSession } from 'next-auth/react'
|
||||
import {
|
||||
ClientSafeProvider,
|
||||
LiteralUnion,
|
||||
signIn,
|
||||
useSession,
|
||||
} from 'next-auth/react'
|
||||
import { useRouter } from 'next/router'
|
||||
import React from 'react'
|
||||
import { stringify } from 'qs'
|
||||
import { FacebookLogo, GoogleLogo, GitlabLogo } from 'assets/logos'
|
||||
import { isEmpty } from 'utils'
|
||||
import { BuiltInProviderType } from 'next-auth/providers'
|
||||
|
||||
export const SocialLoginButtons = () => {
|
||||
type Props = {
|
||||
providers:
|
||||
| Record<LiteralUnion<BuiltInProviderType, string>, ClientSafeProvider>
|
||||
| undefined
|
||||
}
|
||||
|
||||
export const SocialLoginButtons = ({ providers }: Props) => {
|
||||
const { query } = useRouter()
|
||||
const { status } = useSession()
|
||||
|
||||
@ -33,7 +44,7 @@ export const SocialLoginButtons = () => {
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
{!isEmpty(process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID) && (
|
||||
{providers?.github && (
|
||||
<Button
|
||||
leftIcon={<GithubIcon />}
|
||||
onClick={handleGitHubClick}
|
||||
@ -44,7 +55,7 @@ export const SocialLoginButtons = () => {
|
||||
Continue with GitHub
|
||||
</Button>
|
||||
)}
|
||||
{!isEmpty(process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID) && (
|
||||
{providers?.google && (
|
||||
<Button
|
||||
leftIcon={<GoogleLogo />}
|
||||
onClick={handleGoogleClick}
|
||||
@ -55,7 +66,7 @@ export const SocialLoginButtons = () => {
|
||||
Continue with Google
|
||||
</Button>
|
||||
)}
|
||||
{!isEmpty(process.env.NEXT_PUBLIC_FACEBOOK_CLIENT_ID) && (
|
||||
{providers?.facebook && (
|
||||
<Button
|
||||
leftIcon={<FacebookLogo />}
|
||||
onClick={handleFacebookClick}
|
||||
@ -66,7 +77,7 @@ export const SocialLoginButtons = () => {
|
||||
Continue with Facebook
|
||||
</Button>
|
||||
)}
|
||||
{!isEmpty(process.env.NEXT_PUBLIC_GITLAB_CLIENT_ID) && (
|
||||
{providers?.gitlab && (
|
||||
<Button
|
||||
leftIcon={<GitlabLogo />}
|
||||
onClick={handleGitlabClick}
|
||||
@ -74,10 +85,7 @@ export const SocialLoginButtons = () => {
|
||||
isLoading={['loading', 'authenticated'].includes(status)}
|
||||
variant="outline"
|
||||
>
|
||||
Continue with{' '}
|
||||
{isEmpty(process.env.NEXT_PUBLIC_GITLAB_NAME)
|
||||
? 'GitLab'
|
||||
: process.env.NEXT_PUBLIC_GITLAB_NAME}
|
||||
Continue with {providers.gitlab.name}
|
||||
</Button>
|
||||
)}
|
||||
</Stack>
|
||||
|
@ -5,7 +5,7 @@ import { decrypt, encrypt } from 'utils'
|
||||
import prisma from './prisma'
|
||||
|
||||
export const oauth2Client = new OAuth2Client(
|
||||
process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
|
||||
process.env.GOOGLE_CLIENT_ID,
|
||||
process.env.GOOGLE_CLIENT_SECRET,
|
||||
`${process.env.NEXTAUTH_URL}/api/credentials/google-sheets/callback`
|
||||
)
|
||||
|
@ -14,17 +14,17 @@ import { isNotEmpty } from 'utils'
|
||||
|
||||
const providers: Provider[] = []
|
||||
|
||||
if (isNotEmpty(process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID))
|
||||
if (isNotEmpty(process.env.GITHUB_CLIENT_ID))
|
||||
providers.push(
|
||||
GitHubProvider({
|
||||
clientId: process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID,
|
||||
clientId: process.env.GITHUB_CLIENT_ID,
|
||||
clientSecret: process.env.GITHUB_CLIENT_SECRET,
|
||||
})
|
||||
)
|
||||
|
||||
if (
|
||||
isNotEmpty(process.env.NEXT_PUBLIC_SMTP_FROM) &&
|
||||
process.env.NEXT_PUBLIC_SMTP_AUTH_DISABLED !== 'true'
|
||||
process.env.SMTP_AUTH_DISABLED !== 'true'
|
||||
)
|
||||
providers.push(
|
||||
EmailProvider({
|
||||
@ -41,39 +41,40 @@ if (
|
||||
)
|
||||
|
||||
if (
|
||||
isNotEmpty(process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID) &&
|
||||
isNotEmpty(process.env.GOOGLE_CLIENT_ID) &&
|
||||
isNotEmpty(process.env.GOOGLE_CLIENT_SECRET)
|
||||
)
|
||||
providers.push(
|
||||
GoogleProvider({
|
||||
clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
|
||||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
})
|
||||
)
|
||||
|
||||
if (
|
||||
isNotEmpty(process.env.NEXT_PUBLIC_FACEBOOK_CLIENT_ID) &&
|
||||
isNotEmpty(process.env.FACEBOOK_CLIENT_ID) &&
|
||||
isNotEmpty(process.env.FACEBOOK_CLIENT_SECRET)
|
||||
)
|
||||
providers.push(
|
||||
FacebookProvider({
|
||||
clientId: process.env.NEXT_PUBLIC_FACEBOOK_CLIENT_ID,
|
||||
clientId: process.env.FACEBOOK_CLIENT_ID,
|
||||
clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
|
||||
})
|
||||
)
|
||||
|
||||
if (
|
||||
isNotEmpty(process.env.NEXT_PUBLIC_GITLAB_CLIENT_ID) &&
|
||||
isNotEmpty(process.env.GITLAB_CLIENT_ID) &&
|
||||
isNotEmpty(process.env.GITLAB_CLIENT_SECRET)
|
||||
) {
|
||||
const BASE_URL = process.env.GITLAB_BASE_URL || 'https://gitlab.com'
|
||||
providers.push(
|
||||
GitlabProvider({
|
||||
clientId: process.env.NEXT_PUBLIC_GITLAB_CLIENT_ID,
|
||||
clientId: process.env.GITLAB_CLIENT_ID,
|
||||
clientSecret: process.env.GITLAB_CLIENT_SECRET,
|
||||
authorization: `${BASE_URL}/oauth/authorize?scope=read_api`,
|
||||
token: `${BASE_URL}/oauth/token`,
|
||||
userinfo: `${BASE_URL}/api/v4/user`,
|
||||
name: process.env.GITLAB_NAME || 'GitLab',
|
||||
})
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user