@@ -3,7 +3,6 @@ import { Prisma } from 'db'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { googleSheetsScopes } from './consent-url'
|
||||
import { stringify } from 'querystring'
|
||||
import { CredentialsType } from 'models'
|
||||
import { badRequest, encrypt, notAuthenticated } from 'utils/api'
|
||||
import { oauth2Client } from '@/lib/googleSheets'
|
||||
import { getAuthenticatedUser } from '@/features/auth/api'
|
||||
@@ -41,11 +40,11 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const { encryptedData, iv } = encrypt(tokens)
|
||||
const credentials = {
|
||||
name: email,
|
||||
type: CredentialsType.GOOGLE_SHEETS,
|
||||
type: 'google sheets',
|
||||
workspaceId,
|
||||
data: encryptedData,
|
||||
iv,
|
||||
} as Prisma.CredentialsUncheckedCreateInput
|
||||
} satisfies Prisma.CredentialsUncheckedCreateInput
|
||||
const { id: credentialsId } = await prisma.credentials.create({
|
||||
data: credentials,
|
||||
})
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SmtpCredentialsData } from 'models'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { createTransport } from 'nodemailer'
|
||||
import { getAuthenticatedUser } from '@/features/auth/api'
|
||||
import { notAuthenticated } from 'utils/api'
|
||||
import { SmtpCredentials } from 'models'
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const user = await getAuthenticatedUser(req)
|
||||
@@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
if (req.method === 'POST') {
|
||||
const { from, port, isTlsEnabled, username, password, host, to } = (
|
||||
typeof req.body === 'string' ? JSON.parse(req.body) : req.body
|
||||
) as SmtpCredentialsData & { to: string }
|
||||
) as SmtpCredentials['data'] & { to: string }
|
||||
const transporter = createTransport({
|
||||
host,
|
||||
port,
|
||||
|
||||
Reference in New Issue
Block a user