refactor: use hash directly in authmek and version field on authmek

This commit is contained in:
DecDuck
2025-03-24 12:50:21 +11:00
parent cb4937b590
commit 1996b97e99
5 changed files with 30 additions and 45 deletions

View File

@ -2,8 +2,6 @@ import { AuthMec, Invitation } from "@prisma/client";
import prisma from "~/server/internal/db/database";
import {
createHashArgon2,
simpleAuth,
SimpleAuthType,
} from "~/server/internal/security/simple";
import { v4 as uuidv4 } from "uuid";
import * as jdenticon from "jdenticon";
@ -70,17 +68,12 @@ export default defineEventHandler(async (h3) => {
{},
[`internal:read`, `${userId}:write`]
);
const creds: SimpleAuthType = {
version: "v1.0.0",
password: await createHashArgon2(user.password),
};
const [linkMec] = await prisma.$transaction([
prisma.linkedAuthMec.create({
data: {
mec: AuthMec.Simple,
credentials: creds,
credentials: await createHashArgon2(user.password),
version: 2,
user: {
create: {
id: userId,