Skip to content

Commit 19d30ef

Browse files
Simplify flow in sign up controller (#104)
Remove unnecessary conditionals to simplify the code flow
2 parents 42e081d + 4bf2b85 commit 19d30ef

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

server/controllers/signupController.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ signupController.usernameCheck = (req, res, next) => {
1717
.then((data) => {
1818
if (data.rows[0]) {
1919
res.locals.error = 'Username already exists.';
20-
return next();
21-
} else {
22-
return next();
2320
}
21+
return next();
2422
})
2523
.catch((err) => {
2624
return next({
@@ -36,12 +34,10 @@ signupController.passwordCheck = (req, res, next) => {
3634

3735
const { password } = req.body;
3836

39-
if (password.length >= 6) {
40-
return next();
41-
} else {
37+
if (password.length < 6) {
4238
res.locals.error = 'Password must be at least 6 characters.';
43-
return next();
4439
}
40+
return next();
4541
};
4642

4743
// verify user's information is complete
@@ -54,4 +50,4 @@ signupController.completedFormCheck = (req, res, next) => {
5450

5551
// verify admin role
5652

57-
module.exports = signupController;
53+
module.exports = signupController;

0 commit comments

Comments
 (0)