build: 🏗️ Add docker image and deployment features
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// Forked from https://github.com/nextauthjs/adapters/blob/main/packages/prisma/src/index.ts
|
||||
import type { PrismaClient, Prisma, Invitation } from 'db'
|
||||
import { PrismaClient, Prisma, Invitation, Plan } from 'db'
|
||||
import { randomUUID } from 'crypto'
|
||||
import type { Adapter, AdapterUser } from 'next-auth/adapters'
|
||||
import cuid from 'cuid'
|
||||
@ -12,7 +12,12 @@ export function CustomAdapter(p: PrismaClient): Adapter {
|
||||
where: { email: user.email },
|
||||
})
|
||||
const createdUser = await p.user.create({
|
||||
data: { ...data, id: user.id, apiToken: randomUUID() },
|
||||
data: {
|
||||
...data,
|
||||
id: user.id,
|
||||
apiToken: randomUUID(),
|
||||
plan: process.env.ADMIN_EMAIL === data.email ? Plan.PRO : Plan.FREE,
|
||||
},
|
||||
})
|
||||
if (invitations.length > 0)
|
||||
await convertInvitationsToCollaborations(p, user, invitations)
|
||||
|
@ -5,8 +5,6 @@ import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getAuthenticatedUser } from 'services/api/utils'
|
||||
import { methodNotAllowed, notAuthenticated } from 'utils'
|
||||
|
||||
const adminEmail = 'contact@baptiste-arnaud.fr'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const user = await getAuthenticatedUser(req)
|
||||
if (!user) return notAuthenticated(res)
|
||||
@ -81,7 +79,7 @@ const parseWhereFilter = (
|
||||
{
|
||||
id: typebotId,
|
||||
ownerId:
|
||||
(type === 'read' && user.email === adminEmail) ||
|
||||
(type === 'read' && user.email === process.env.ADMIN_EMAIL) ||
|
||||
process.env.NEXT_PUBLIC_E2E_TEST
|
||||
? undefined
|
||||
: user.id,
|
||||
|
@ -5,8 +5,6 @@ import { getAuthenticatedUser } from 'services/api/utils'
|
||||
import { isFreePlan } from 'services/user/user'
|
||||
import { methodNotAllowed, notAuthenticated } from 'utils'
|
||||
|
||||
const adminEmail = 'contact@baptiste-arnaud.fr'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const user = await getAuthenticatedUser(req)
|
||||
if (!user) return notAuthenticated(res)
|
||||
@ -24,7 +22,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
: undefined,
|
||||
where: {
|
||||
typebotId,
|
||||
typebot: { ownerId: user.email === adminEmail ? undefined : user.id },
|
||||
typebot: {
|
||||
ownerId: user.email === process.env.ADMIN_EMAIL ? undefined : user.id,
|
||||
},
|
||||
answers: { some: {} },
|
||||
isCompleted: isFreePlan(user) ? true : undefined,
|
||||
},
|
||||
|
Reference in New Issue
Block a user