Skip to content

Commit 0f78ead

Browse files
committed
Refactor config to include security.requireEmailVerification
1 parent 0ed0407 commit 0f78ead

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import dotenv from "dotenv";
44
dotenv.config();
55

66
export default {
7+
security: {
8+
requireEmailVerification:
9+
process.env.REQUIRE_EMAIL_VERIFICATION === "true" || true,
10+
},
711
db: {
812
user: process.env.DB_USER || "postgres",
913
host: process.env.DB_HOST || "localhost",

src/routers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { HealthCheckResponse } from "./types";
1818
import configuration from "./config";
1919
import { AUTHORITIES, getAccountAuthorities } from "./authorities";
20+
import config from "./config";
2021

2122
export function handleRoutes(app: Express) {
2223
app.get("/", (req: Request, res: Response) => {
@@ -85,7 +86,10 @@ export function handleRoutes(app: Express) {
8586
return res.status(401).json({ message: "Invalid credentials" });
8687
}
8788

88-
if (!userInfo.is_email_verified) {
89+
if (
90+
config.security.requireEmailVerification &&
91+
!userInfo.is_email_verified
92+
) {
8993
return res.status(403).json({ message: "Email is not verified" });
9094
}
9195

0 commit comments

Comments
 (0)