@@ -54,7 +54,7 @@ function login(req, res, next) {
5454 error : { }
5555 } ) ;
5656 }
57- next ( ) ;
57+ return next ( ) ;
5858 } ) ;
5959 } ) ( req , res , next ) ;
6060}
@@ -66,15 +66,15 @@ function login(req, res, next) {
6666function ensureAuthenticated ( ) {
6767 return function ( req , res , next ) {
6868 if ( req . isUnauthenticated ( ) ) {
69- next ( {
69+ return next ( {
7070 status : 401 ,
7171 message : Constants . Error . AUTH_401_MESSAGE ,
7272 error : {
7373 route : req . path
7474 }
7575 } ) ;
7676 } else {
77- next ( ) ;
77+ return next ( ) ;
7878 }
7979 } ;
8080}
@@ -89,19 +89,19 @@ function ensureAuthorized(findByIdFns) {
8989 Services . Auth . ensureAuthorized ( req , findByIdFns ) . then (
9090 ( auth ) => {
9191 if ( ! auth ) {
92- next ( {
92+ return next ( {
9393 status : 403 ,
9494 message : Constants . Error . AUTH_403_MESSAGE ,
9595 error : {
9696 route : req . path
9797 }
9898 } ) ;
9999 } else {
100- next ( ) ;
100+ return next ( ) ;
101101 }
102102 } ,
103103 ( err ) => {
104- next ( err ) ;
104+ return next ( err ) ;
105105 }
106106 ) ;
107107 } ;
@@ -122,7 +122,7 @@ async function retrieveRoleBindings(req, res, next) {
122122 } )
123123 }
124124 req . roleBindings = roleBindings ;
125- next ( ) ;
125+ return next ( ) ;
126126}
127127
128128/**
@@ -144,9 +144,9 @@ async function sendResetPasswordEmailMiddleware(req, res, next) {
144144 if ( mailData !== undefined ) {
145145 Services . Email . send ( mailData , ( err ) => {
146146 if ( err ) {
147- next ( err ) ;
147+ return next ( err ) ;
148148 } else {
149- next ( ) ;
149+ return next ( ) ;
150150 }
151151 } ) ;
152152 } else {
@@ -156,7 +156,7 @@ async function sendResetPasswordEmailMiddleware(req, res, next) {
156156 }
157157 } else {
158158 //Didn't find the user, but we don't want to throw an error because someone might be trying to see who has an account.
159- next ( ) ;
159+ return next ( ) ;
160160 }
161161}
162162
@@ -180,9 +180,9 @@ async function sendConfirmAccountEmailMiddleware(req, res, next) {
180180 if ( mailData !== undefined ) {
181181 Services . Email . send ( mailData , ( err ) => {
182182 if ( err ) {
183- next ( err ) ;
183+ return next ( err ) ;
184184 } else {
185- next ( ) ;
185+ return next ( ) ;
186186 }
187187 } ) ;
188188 } else {
@@ -218,9 +218,9 @@ async function resendConfirmAccountEmail(req, res, next) {
218218 if ( mailData !== undefined ) {
219219 Services . Email . send ( mailData , ( err ) => {
220220 if ( err ) {
221- next ( err ) ;
221+ return next ( err ) ;
222222 } else {
223- next ( ) ;
223+ return next ( ) ;
224224 }
225225 } ) ;
226226 } else {
@@ -240,10 +240,10 @@ async function resendConfirmAccountEmail(req, res, next) {
240240function parseResetToken ( req , res , next ) {
241241 jwt . verify ( req . body [ 'x-reset-token' ] , process . env . JWT_RESET_PWD_SECRET , function ( err , decoded ) {
242242 if ( err ) {
243- next ( err ) ;
243+ return next ( err ) ;
244244 } else {
245245 req . body . decodedToken = decoded ;
246- next ( ) ;
246+ return next ( ) ;
247247 }
248248 } ) ;
249249}
@@ -260,13 +260,13 @@ function parseAccountConfirmationToken(req, res, next) {
260260 if ( ! ! req . body . token ) {
261261 jwt . verify ( req . body . token , process . env . JWT_CONFIRM_ACC_SECRET , function ( err , decoded ) {
262262 if ( err ) {
263- next ( err ) ;
263+ return next ( err ) ;
264264 } else {
265265 req . body . decodedToken = decoded ;
266266 }
267267 } ) ;
268268 }
269- next ( ) ;
269+ return next ( ) ;
270270}
271271
272272/**
@@ -279,10 +279,10 @@ async function getAccountTypeFromConfirmationToken(req, res, next) {
279279 const confirmationObj = await Services . AccountConfirmation . findById ( req . body . decodedToken . accountConfirmationId ) ;
280280 if ( confirmationObj ) {
281281 req . body . accountType = confirmationObj . accountType ;
282- next ( ) ;
282+ return next ( ) ;
283283 } else {
284284 //Either the token was already used, it's invalid, or user does not exist.
285- next ( {
285+ return next ( {
286286 status : 401 ,
287287 message : Constants . Error . ACCOUNT_TOKEN_401_MESSAGE ,
288288 error : { }
@@ -301,10 +301,10 @@ async function validateResetToken(req, res, next) {
301301 const userObj = await Services . Account . findById ( req . body . decodedToken . accountId ) ;
302302 if ( resetObj && userObj ) {
303303 req . body . user = userObj ;
304- next ( ) ;
304+ return next ( ) ;
305305 } else {
306306 //Either the token was already used, it's invalid, or user does not exist.
307- next ( {
307+ return next ( {
308308 status : 401 ,
309309 message : Constants . Error . ACCOUNT_TOKEN_401_MESSAGE ,
310310 error : { }
@@ -326,10 +326,10 @@ async function validateConfirmationToken(req, res, next) {
326326 userObj . accountType = confirmationObj . accountType ;
327327 await Services . Account . updateOne ( confirmationObj . accountId , userObj ) ;
328328 req . body . user = userObj ;
329- next ( ) ;
329+ return next ( ) ;
330330 } else {
331331 //Either the token was already used, it's invalid, or user does not exist.
332- next ( {
332+ return next ( {
333333 status : 401 ,
334334 message : Constants . Error . ACCOUNT_TOKEN_401_MESSAGE ,
335335 error : { }
@@ -351,7 +351,7 @@ async function validateConfirmationTokenWithoutAccount(req, res, next) {
351351 req . body . accountDetails . accountType = confirmationObj . accountType ;
352352 }
353353 }
354- next ( ) ;
354+ return next ( ) ;
355355}
356356
357357
@@ -364,10 +364,10 @@ async function validateConfirmationTokenWithoutAccount(req, res, next) {
364364function deleteResetToken ( req , res , next ) {
365365 Services . ResetPasswordToken . deleteToken ( req . body . decodedToken . resetId ) . then (
366366 ( ) => {
367- next ( ) ;
367+ return next ( ) ;
368368 } ,
369369 ( err ) => {
370- next ( err ) ;
370+ return next ( err ) ;
371371 }
372372 ) ;
373373}
@@ -384,7 +384,7 @@ async function addCreationRoleBindings(req, res, next) {
384384 await Services . RoleBinding . createRoleBindingByRoleName ( req . body . account . id , roleName ) ;
385385 // Add default account role bindings
386386 await Services . RoleBinding . createRoleBindingByRoleName ( req . body . account . id , Constants . Role . accountRole . name ) ;
387- next ( ) ;
387+ return next ( ) ;
388388}
389389
390390/**
@@ -394,7 +394,7 @@ async function addCreationRoleBindings(req, res, next) {
394394function createRoleBindings ( roleName = undefined ) {
395395 return Middleware . Util . asyncMiddleware ( async ( req , res , next ) => {
396396 await Services . RoleBinding . createRoleBindingByRoleName ( req . user . id , roleName ) ;
397- next ( ) ;
397+ return next ( ) ;
398398 } ) ;
399399}
400400
@@ -407,7 +407,7 @@ function createRoleBindings(roleName = undefined) {
407407async function retrieveRoles ( req , res , next ) {
408408 const roles = await Services . Role . getAll ( ) ;
409409 req . roles = roles ;
410- next ( ) ;
410+ return next ( ) ;
411411}
412412
413413module . exports = {
0 commit comments