mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 13:32:08 +01:00
Potential fix for code scanning alert no. 1: Insecure randomness
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import crypto from "crypto";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { prisma } from "../../../lib/prisma";
|
||||
import bcrypt from "bcryptjs";
|
||||
@ -43,7 +44,7 @@ export default async function handler(
|
||||
return res.status(400).json({ error: "Missing fields" });
|
||||
const exists = await prisma.user.findUnique({ where: { email } });
|
||||
if (exists) return res.status(409).json({ error: "Email exists" });
|
||||
const tempPassword = Math.random().toString(36).slice(-8); // random initial password
|
||||
const tempPassword = crypto.randomBytes(12).toString('base64').slice(0, 12); // secure random initial password
|
||||
await prisma.user.create({
|
||||
data: {
|
||||
email,
|
||||
|
||||
Reference in New Issue
Block a user