Skip to content

Commit 5dc016f

Browse files
committed
Refactor dbQueries to include is_locked field in queryAccountInfoByEmail function
1 parent 869207e commit 5dc016f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/helpers/dbQueries.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ type Account = {
44
id: number;
55
password: string;
66
is_email_verified: boolean;
7+
is_locked: boolean;
78
};
89

910
export async function queryAccountInfoByEmail(
1011
email: string
1112
): Promise<Account | null> {
1213
try {
1314
const result = await query(
14-
"SELECT id,password,is_email_verified FROM accounts WHERE email = $1",
15+
"SELECT id,password,is_email_verified,is_locked FROM accounts WHERE email = $1",
1516
[email]
1617
);
1718

src/routers.ts

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

89+
if (userInfo.is_locked) {
90+
return res.status(403).json({ message: "Account is locked" });
91+
}
92+
8993
if (
9094
config.security.requireEmailVerification &&
9195
!userInfo.is_email_verified

src/utils/guards.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)