Skip to content

Commit

Permalink
remove next-auth debug mode, increased generations to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutlope committed Mar 10, 2023
1 parent a2282c7 commit 4a2bb40
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { PrismaAdapter } from "@next-auth/prisma-adapter";
import prisma from "../../../lib/prismadb";

export const authOptions: NextAuthOptions = {
debug: true,
adapter: PrismaAdapter(prisma),
providers: [
GoogleProvider({
Expand Down
4 changes: 2 additions & 2 deletions pages/api/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ interface ExtendedNextApiRequest extends NextApiRequest {
};
}

// Create a new ratelimiter, that allows 2 requests per 24 hours
// Create a new ratelimiter, that allows 3 requests per 24 hours
const ratelimit = redis
? new Ratelimit({
redis: redis,
limiter: Ratelimit.fixedWindow(2, "1440 m"),
limiter: Ratelimit.fixedWindow(3, "1440 m"),
analytics: true,
})
: undefined;
Expand Down
4 changes: 2 additions & 2 deletions pages/api/remaining.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default async function handler(
const session = await getServerSession(req, res, authOptions);
if (!session || !session.user) {
console.log("User not logged in");
return res.status(500).json("Login to upload.");
return res.status(401).json("Login to upload.");
}

// Query the redis database by email to get the number of generations left
Expand Down Expand Up @@ -39,7 +39,7 @@ export default async function handler(
const minutes = Math.floor(diff / 1000 / 60) - hours * 60;

const remainingGenerations =
Number(usedGenerations) > 2 ? 0 : 2 - Number(usedGenerations);
Number(usedGenerations) > 3 ? 0 : 3 - Number(usedGenerations);

return res.status(200).json({ remainingGenerations, hours, minutes });
}

0 comments on commit 4a2bb40

Please sign in to comment.