Skip to content

Commit 0ed0407

Browse files
committed
Refactor dbQueries to use Account type instead of accountInfo and block non verified emails
1 parent f1cb348 commit 0ed0407

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/helpers/dbQueries.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { query } from "../utils/db";
22

3-
type accountInfo = {
3+
type Account = {
44
id: number;
55
password: string;
6+
is_email_verified: boolean;
67
};
78

89
export async function queryAccountInfoByEmail(
910
email: string
10-
): Promise<accountInfo | null> {
11+
): Promise<Account | null> {
1112
try {
1213
const result = await query(
1314
"SELECT id,password FROM accounts WHERE email = $1",

src/routers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export function handleRoutes(app: Express) {
8585
return res.status(401).json({ message: "Invalid credentials" });
8686
}
8787

88+
if (!userInfo.is_email_verified) {
89+
return res.status(403).json({ message: "Email is not verified" });
90+
}
91+
8892
const token = generateToken({ email: email, sub: userInfo.id });
8993

9094
res.json({ token });

0 commit comments

Comments
 (0)