Skip to content

Commit

Permalink
Refactor dbQueries to include is_locked field in queryAccountInfoByEm…
Browse files Browse the repository at this point in the history
…ail function
  • Loading branch information
Wassim-Rached committed Oct 19, 2024
1 parent 869207e commit 5dc016f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/helpers/dbQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ type Account = {
id: number;
password: string;
is_email_verified: boolean;
is_locked: boolean;
};

export async function queryAccountInfoByEmail(
email: string
): Promise<Account | null> {
try {
const result = await query(
"SELECT id,password,is_email_verified FROM accounts WHERE email = $1",
"SELECT id,password,is_email_verified,is_locked FROM accounts WHERE email = $1",
[email]
);

Expand Down
4 changes: 4 additions & 0 deletions src/routers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export function handleRoutes(app: Express) {
return res.status(401).json({ message: "Invalid credentials" });
}

if (userInfo.is_locked) {
return res.status(403).json({ message: "Account is locked" });
}

if (
config.security.requireEmailVerification &&
!userInfo.is_email_verified
Expand Down
Empty file removed src/utils/guards.ts
Empty file.

0 comments on commit 5dc016f

Please sign in to comment.