diff --git a/package.json b/package.json index e9f96b7..e95b642 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chadnext", - "version": "1.6.0", + "version": "1.7.0", "private": true, "scripts": { "dev": "prisma generate && next dev", diff --git a/src/actions/auth.ts b/src/actions/auth.ts index 84548aa..368d547 100644 --- a/src/actions/auth.ts +++ b/src/actions/auth.ts @@ -2,11 +2,13 @@ import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; -import { alphabet, generateRandomString } from "oslo/crypto"; +import { generateRandomString, RandomReader } from "@oslojs/crypto/random"; import { deleteSessionTokenCookie } from "~/lib/server/cookies"; import prisma from "~/lib/server/prisma"; import { getCurrentSession, invalidateSession } from "~/lib/server/session"; +const digits = "0123456789"; + export async function logout() { const { session } = await getCurrentSession(); if (!session) { @@ -30,7 +32,12 @@ export async function generateEmailVerificationCode( userId, }, }); - const code = generateRandomString(6, alphabet("0-9")); + const random: RandomReader = { + read(bytes) { + crypto.getRandomValues(bytes); + }, + }; + const code = generateRandomString(random, digits, 6); await prisma.emailVerificationCode.create({ data: { userId,