implemented stripe for the cloud instance

This commit is contained in:
Daniel
2023-07-15 22:15:43 -04:00
parent 0b66e16123
commit f82582a0bd
29 changed files with 474 additions and 88 deletions
+7 -5
View File
@@ -2,7 +2,7 @@ import { prisma } from "@/lib/api/db";
import type { NextApiRequest, NextApiResponse } from "next";
import bcrypt from "bcrypt";
const EmailProvider =
const emailEnabled =
process.env.EMAIL_FROM && process.env.EMAIL_SERVER ? true : false;
interface Data {
@@ -22,7 +22,7 @@ export default async function Index(
) {
const body: User = req.body;
const checkHasEmptyFields = EmailProvider
const checkHasEmptyFields = emailEnabled
? !body.username || !body.password || !body.name || !body.email
: !body.username || !body.password || !body.name;
@@ -34,7 +34,7 @@ export default async function Index(
const tenMinutesAgo = new Date(Date.now() - 10 * 60 * 1000);
// Remove user's who aren't verified for more than 10 minutes
if (EmailProvider)
if (emailEnabled)
await prisma.user.deleteMany({
where: {
OR: [
@@ -53,10 +53,12 @@ export default async function Index(
});
const checkIfUserExists = await prisma.user.findFirst({
where: EmailProvider
where: emailEnabled
? {
OR: [
{ username: body.username.toLowerCase() },
{
username: body.username.toLowerCase(),
},
{
email: body.email?.toLowerCase(),
},