mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-04 10:05:53 +02:00
setup react email and nodemailer
This commit is contained in:
parent
c9d98a8e8c
commit
57ebc0e525
11 changed files with 2497 additions and 4754 deletions
|
@ -1,5 +1,4 @@
|
|||
import { Request, Response, NextFunction } from "express";
|
||||
import { verifySession } from "@server/auth";
|
||||
import createHttpError from "http-errors";
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
import { fromError } from "zod-validation-error";
|
||||
|
@ -7,7 +6,7 @@ import { unauthorized } from "@server/auth";
|
|||
import { z } from "zod";
|
||||
import { verify } from "@node-rs/argon2";
|
||||
import { db } from "@server/db";
|
||||
import { users } from "@server/db/schema";
|
||||
import { User, users } from "@server/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { response } from "@server/utils";
|
||||
|
||||
|
@ -34,24 +33,9 @@ export async function disable2fa(
|
|||
}
|
||||
|
||||
const { password } = parsedBody.data;
|
||||
const user = req.user as User;
|
||||
|
||||
const { session, user } = await verifySession(req);
|
||||
if (!session) {
|
||||
return next(unauthorized());
|
||||
}
|
||||
|
||||
const existingUser = await db
|
||||
.select()
|
||||
.from(users)
|
||||
.where(eq(users.id, user.id));
|
||||
|
||||
if (!existingUser || !existingUser[0]) {
|
||||
return next(
|
||||
createHttpError(HttpCode.BAD_REQUEST, "User does not exist"),
|
||||
);
|
||||
}
|
||||
|
||||
const validPassword = await verify(existingUser[0].passwordHash, password, {
|
||||
const validPassword = await verify(user.passwordHash, password, {
|
||||
memoryCost: 19456,
|
||||
timeCost: 2,
|
||||
outputLen: 32,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue