@@ -41,11 +41,9 @@ const userController = {
4141
4242 // middleware for verifying a user on login
4343 verifyUser : async ( req : Request , res : Response , next : NextFunction ) => {
44- // obtain user name password from request body
4544 // obtain user name password from request body
4645 const { username, password } = req . body ;
4746 // check for a missing input
48- // check for a missing input
4947 if ( ! username || ! password ) {
5048 return next ( {
5149 log : "Missing username or password in verifyUser" ,
@@ -54,23 +52,19 @@ const userController = {
5452 } ) ;
5553 }
5654 try {
57- // search DB for the user based on the username
5855 // search DB for the user based on the username
5956 const user = await User . findOne ( { username } ) ;
6057 // if now user is found error out
61- // if now user is found error out
6258 if ( ! user ) {
6359 return next ( {
6460 log : `userController.verifyUser ERROR: no user with input username found in DB` ,
6561 status : 400 ,
6662 message : { err : "Invalid username or password" } ,
6763 } ) ;
6864 } else {
69- // else a user is found, check passwords
7065 // else a user is found, check passwords
7166 const resultPassword = await bcrypt . compare ( password , user . password ) ;
7267 // if passwords do not match error out
73- // if passwords do not match error out
7468 if ( ! resultPassword ) {
7569 return next ( {
7670 log : `userController.verifyUser ERROR: input password does not match stored password` ,
@@ -89,12 +83,6 @@ const userController = {
8983 status : 500 ,
9084 message : { err : "Error occured creating user" } ,
9185 } ) ;
92- // send any errors to global error handler
93- return next ( {
94- log : `usersController.createUser ERROR: ${ err } ` ,
95- status : 500 ,
96- message : { err : "Error occured creating user" } ,
97- } ) ;
9886 }
9987 } ,
10088} ;
0 commit comments