Skip to content

Commit

Permalink
hotfix: update oslojs codes
Browse files Browse the repository at this point in the history
  • Loading branch information
moinulmoin committed Nov 23, 2024
1 parent 6f8704e commit 7b5b22b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chadnext",
"version": "1.6.0",
"version": "1.7.0",
"private": true,
"scripts": {
"dev": "prisma generate && next dev",
Expand Down
11 changes: 9 additions & 2 deletions src/actions/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit 7b5b22b

Please sign in to comment.