Skip to content
Snippets Groups Projects
Commit ae9002ec authored by Caner's avatar Caner
Browse files

env.mjs update

parent 17b0344a
No related branches found
No related tags found
1 merge request!45Email verify
import { db } from '@/lib/db'
import { randomUUID } from 'crypto';
import { redirect } from 'next/navigation'
import { NextRequest } from 'next/server'
......@@ -40,7 +39,7 @@ export async function GET(
throw new Error('Token is invalid or expired')
}
await db.user.update({
const userUpdate = await db.user.update({
where: {
id: user.id,
},
......@@ -49,7 +48,7 @@ export async function GET(
},
})
await db.activationToken.update({
const actiaction = await db.activationToken.update({
where: {
token,
},
......@@ -57,6 +56,6 @@ export async function GET(
activationDate: new Date(),
},
})
redirect('/Verification')
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import { NextResponse } from "next/server";
import { db } from "@/lib/db";
import { randomUUID } from "crypto";
import getURL from "@/lib/utils";
import { env } from "@/env.mjs";
export async function POST(req: Request) {
const { email} = await req.json();
......@@ -11,8 +12,8 @@ export async function POST(req: Request) {
service: 'gmail',
host: 'smtp.gmail.com',
auth: {
user: process.env.NODEMAIL_MAIL,
pass: process.env.NODEMAIL_PW,
user: env.NODEMAIL_MAIL,
pass: env.NODEMAIL_PW,
},
});
......@@ -30,7 +31,7 @@ export async function POST(req: Request) {
});
const mailData = {
from: process.env.NODEMAIL_MAIL,
from: env.NODEMAIL_MAIL,
to: email,
subject: `Email Verification for your GameUnity Account`,
html: `Hello ${user?.name} Please follow the Link: ${getURL(`/api/verification/${token.token}`)} and verify your email address.`,
......
......@@ -15,6 +15,8 @@ export const env = createEnv({
TWITCH_AUTH_BASE_URL: z.string().url().optional(),
IGDB_BASE_URL: z.string().url().optional(),
IGDB_IMG_BASE_URL: z.string().url().optional(),
NODEMAIL_MAIL: z.string().min(1),
NODEMAIL_PW: z.string().min(1),
},
client: {
NEXT_PUBLIC_APP_URL: z.string().min(1),
......@@ -33,5 +35,7 @@ export const env = createEnv({
TWITCH_AUTH_BASE_URL: process.env.TWITCH_AUTH_BASE_URL,
IGDB_BASE_URL: process.env.IGDB_BASE_URL,
IGDB_IMG_BASE_URL: process.env.IGDB_IMG_BASE_URL,
NODEMAIL_MAIL: process.env.NODEMAIL_MAIL,
NODEMAIL_PW: process.env.NODEMAIL_PW,
},
})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment