mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-29 06:08:15 +02:00
ability to disable email verification requirement
This commit is contained in:
parent
50e1a7abe1
commit
29b848fd5d
7 changed files with 107 additions and 53 deletions
|
@ -6,11 +6,12 @@ import { users } from "@server/db/schema";
|
|||
import { eq } from "drizzle-orm";
|
||||
import createHttpError from "http-errors";
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
import config from "@server/config";
|
||||
|
||||
export const verifySessionUserMiddleware = async (
|
||||
req: any,
|
||||
res: Response<ErrorResponse>,
|
||||
next: NextFunction,
|
||||
next: NextFunction
|
||||
) => {
|
||||
const { session, user } = await verifySession(req);
|
||||
if (!session || !user) {
|
||||
|
@ -24,16 +25,19 @@ export const verifySessionUserMiddleware = async (
|
|||
|
||||
if (!existingUser || !existingUser[0]) {
|
||||
return next(
|
||||
createHttpError(HttpCode.BAD_REQUEST, "User does not exist"),
|
||||
createHttpError(HttpCode.BAD_REQUEST, "User does not exist")
|
||||
);
|
||||
}
|
||||
|
||||
req.user = existingUser[0];
|
||||
req.session = session;
|
||||
|
||||
if (!existingUser[0].emailVerified) {
|
||||
if (
|
||||
!existingUser[0].emailVerified &&
|
||||
config.flags?.require_email_verification
|
||||
) {
|
||||
return next(
|
||||
createHttpError(HttpCode.BAD_REQUEST, "Email is not verified"), // Might need to change the response type?
|
||||
createHttpError(HttpCode.BAD_REQUEST, "Email is not verified") // Might need to change the response type?
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue