Skip to content

Commit

Permalink
refactor: remove unused postmark code
Browse files Browse the repository at this point in the history
  • Loading branch information
shadcn committed Dec 5, 2022
1 parent 44e89d4 commit 9c4461b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
8 changes: 1 addition & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ DATABASE_URL="mysql://root:root@localhost:3306/taxonomy?schema=public"
# -----------------------------------------------------------------------------
# Email (Postmark)
# -----------------------------------------------------------------------------
SMTP_FROM=
POSTMARK_API_TOKEN=
POSTMARK_SIGN_IN_TEMPLATE=
POSTMARK_ACTIVATION_TEMPLATE=
SMTP_HOST=smtp.postmarkapp.com
SMTP_PORT=25
SMTP_USER=
SMTP_PASSWORD=
SMTP_FROM=
const POSTMARK_SIGN_IN_TEMPLATE=
const POSTMARK_ACTIVATION_TEMPLATE=

# -----------------------------------------------------------------------------
# Subscriptions (Stripe)
Expand Down
25 changes: 6 additions & 19 deletions lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ import { PrismaAdapter } from "@next-auth/prisma-adapter"
import { Client } from "postmark"

import { db } from "@/lib/db"
import { siteConfig } from "@/config/site"

const postmarkClient = new Client(process.env.POSTMARK_API_TOKEN)

const POSTMARK_SIGN_IN_TEMPLATE = parseInt(
process.env.POSTMARK_SIGN_IN_TEMPLATE
)
const POSTMARK_ACTIVATION_TEMPLATE = parseInt(
process.env.POSTMARK_ACTIVATION_TEMPLATE
)

export const authOptions: NextAuthOptions = {
// huh any! I know.
// This is a temporary fix for prisma client.
Expand All @@ -32,14 +26,6 @@ export const authOptions: NextAuthOptions = {
clientSecret: process.env.GITHUB_CLIENT_SECRET,
}),
EmailProvider({
server: {
host: process.env.SMTP_HOST,
port: Number(process.env.SMTP_PORT),
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASSWORD,
},
},
from: process.env.SMTP_FROM,
sendVerificationRequest: async ({ identifier, url, provider }) => {
const user = await db.user.findUnique({
Expand All @@ -51,15 +37,16 @@ export const authOptions: NextAuthOptions = {
},
})

const templateId = user?.emailVerified
? process.env.POSTMARK_SIGN_IN_TEMPLATE
: process.env.POSTMARK_ACTIVATION_TEMPLATE
const result = await postmarkClient.sendEmailWithTemplate({
TemplateId: user?.emailVerified
? POSTMARK_SIGN_IN_TEMPLATE
: POSTMARK_ACTIVATION_TEMPLATE,
TemplateId: parseInt(templateId),
To: identifier,
From: provider.from,
TemplateModel: {
action_url: url,
product_name: "Taxonomy",
product_name: siteConfig.name,
},
Headers: [
{
Expand Down

0 comments on commit 9c4461b

Please sign in to comment.