Skip to content

Commit

Permalink
Fix code scanning alert no. 1: Insecure randomness
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
dinxsh and github-advanced-security[bot] authored Dec 18, 2024
1 parent 4592cae commit 24fa128
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/api/sign-up/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { sendVerificationEmail } from "../../../components/emails/sendVerificati
import dbConnect from "../../../lib/dbConnect";
import UserModel from "../../../model/User";
import bcrypt from "bcryptjs";
import crypto from "crypto";

export async function POST(request) {
await dbConnect();
Expand All @@ -23,7 +24,7 @@ export async function POST(request) {

const existingUserByEmail = await UserModel.findOne({ email });

let verifyCode = Math.floor(100000 + Math.random() * 900000).toString();
let verifyCode = crypto.randomInt(100000, 1000000).toString();

if (existingUserByEmail) {
if (existingUserByEmail.twoFactorActivated) {
Expand Down

0 comments on commit 24fa128

Please sign in to comment.