Skip to content

Commit efe743f

Browse files
codinghack30mm000810golden0810
committed
change verify processor
Co-Authored-By: codinghack0810 <178182017+codinghack0810@users.noreply.github.com> Co-Authored-By: mm000810 <178183308+mm000810@users.noreply.github.com> Co-Authored-By: golden0810 <178187133+golden0810@users.noreply.github.com>
1 parent 54f0625 commit efe743f

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/controllers/user.controller.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ const signup = async (req, res) => {
3636

3737
const userAccount = await UserAccount.findOne({ where: { email } });
3838
if (userAccount) {
39-
return res.status(400).json({ msg: "User already exists." });
39+
if (userAccount.active !== 1) {
40+
return res
41+
.status(400)
42+
.json({ msg: "User is not verified. Please verify." });
43+
} else {
44+
return res.status(400).json({ msg: "User already exists." });
45+
}
4046
}
4147

4248
// Create the user account

src/controllers/verify.controller.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const sendCode = async (req, res) => {
1313

1414
// Check if the user exists
1515
if (!userAccount) {
16-
return res.status(404).json({ msg: "User does not exist." });
16+
return res.status(404).json({ msg: "User did not signup." });
1717
}
1818

1919
// Check if the user is already verified
@@ -61,11 +61,12 @@ const sendCode = async (req, res) => {
6161
const verifyCode = async (req, res) => {
6262
try {
6363
const { email, code } = req.body;
64+
6465
const userAccount = await UserAccount.findOne({ where: { email } });
6566

6667
// Check if the user exists
6768
if (!userAccount) {
68-
return res.status(404).json({ msg: "User does not exist." });
69+
return res.status(404).json({ msg: "User did not signup." });
6970
}
7071

7172
// Check if the user is already verified

src/middlewares/requiredVerify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = async (req, res, next) => {
88
// Check if the user exists
99
const userAccount = await UserAccount.findOne({ where: { email } });
1010
if (!userAccount) {
11-
return res.status(404).json({ msg: "User does not exist." });
11+
return res.status(404).json({ msg: "User does not exist. Please signed up." });
1212
}
1313

1414
// Check if the user is already verified

0 commit comments

Comments
 (0)