Skip to content

Commit

Permalink
bugfix: configure swagger documentation url and login by checking sta…
Browse files Browse the repository at this point in the history
…tus and verified fields
  • Loading branch information
amin-leon committed Apr 29, 2024
1 parent c9bbce0 commit 6fa2e2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/controllers/authController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ const login = async (req: Request, res: Response): Promise<void> => {
return;
}

// Check if user is inactive
if (user.status === 'inactive') {
logger.error('Your account has been blocked. Please contact support.');
res.status(403).json({ ok: false, message: 'Your account has been blocked. Please contact support.' });
return;
}

// Check if user is verified
if (!user.verified) {
logger.error('Your account is not verified. Please verify your account.');
res.status(403).json({ ok: false, message: 'Your account is not verified. Please verify your account.' });
return;
}

// Verify password
const passwordValid = await bcrypt.compare(password, user.password);
if (!passwordValid) {
Expand Down
2 changes: 1 addition & 1 deletion src/docs/swaggerdocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const options = {
},
servers: [
{
url: `${process.env.URL_HOST}:${process.env.PORT}`,
url: `${process.env.URL_HOST}`,
},
],
},
Expand Down

0 comments on commit 6fa2e2e

Please sign in to comment.