@@ -53,7 +53,7 @@ function login(req, res, next) {
5353 error : { }
5454 } ) ;
5555 }
56- next ( ) ;
56+ return next ( ) ;
5757 } ) ;
5858 } ) ( req , res , next ) ;
5959}
@@ -65,15 +65,15 @@ function login(req, res, next) {
6565function ensureAuthenticated ( ) {
6666 return function ( req , res , next ) {
6767 if ( req . isUnauthenticated ( ) ) {
68- next ( {
68+ return next ( {
6969 status : 401 ,
7070 message : Constants . Error . AUTH_401_MESSAGE ,
7171 error : {
7272 route : req . path
7373 }
7474 } ) ;
7575 } else {
76- next ( ) ;
76+ return next ( ) ;
7777 }
7878 } ;
7979}
@@ -88,19 +88,19 @@ function ensureAuthorized(findByIdFns) {
8888 Services . Auth . ensureAuthorized ( req , findByIdFns ) . then (
8989 ( auth ) => {
9090 if ( ! auth ) {
91- next ( {
91+ return next ( {
9292 status : 403 ,
9393 message : Constants . Error . AUTH_403_MESSAGE ,
9494 error : {
9595 route : req . path
9696 }
9797 } ) ;
9898 } else {
99- next ( ) ;
99+ return next ( ) ;
100100 }
101101 } ,
102102 ( err ) => {
103- next ( err ) ;
103+ return next ( err ) ;
104104 }
105105 ) ;
106106 } ;
@@ -121,7 +121,7 @@ async function retrieveRoleBindings(req, res, next) {
121121 } )
122122 }
123123 req . roleBindings = roleBindings ;
124- next ( ) ;
124+ return next ( ) ;
125125}
126126
127127/**
@@ -145,9 +145,9 @@ async function sendResetPasswordEmailMiddleware(req, res, next) {
145145 if ( mailData !== undefined ) {
146146 Services . Email . send ( mailData , ( err ) => {
147147 if ( err ) {
148- next ( err ) ;
148+ return next ( err ) ;
149149 } else {
150- next ( ) ;
150+ return next ( ) ;
151151 }
152152 } ) ;
153153 } else {
@@ -157,7 +157,7 @@ async function sendResetPasswordEmailMiddleware(req, res, next) {
157157 }
158158 } else {
159159 //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.
160- next ( ) ;
160+ return next ( ) ;
161161 }
162162}
163163
@@ -178,9 +178,9 @@ async function sendConfirmAccountEmailMiddleware(req, res, next) {
178178 if ( mailData !== undefined ) {
179179 Services . Email . send ( mailData , ( err ) => {
180180 if ( err ) {
181- next ( err ) ;
181+ return next ( err ) ;
182182 } else {
183- next ( ) ;
183+ return next ( ) ;
184184 }
185185 } ) ;
186186 } else {
@@ -216,9 +216,9 @@ async function resendConfirmAccountEmail(req, res, next) {
216216 if ( mailData !== undefined ) {
217217 Services . Email . send ( mailData , ( err ) => {
218218 if ( err ) {
219- next ( err ) ;
219+ return next ( err ) ;
220220 } else {
221- next ( ) ;
221+ return next ( ) ;
222222 }
223223 } ) ;
224224 } else {
@@ -238,10 +238,10 @@ async function resendConfirmAccountEmail(req, res, next) {
238238function parseResetToken ( req , res , next ) {
239239 jwt . verify ( req . body [ 'x-reset-token' ] , process . env . JWT_RESET_PWD_SECRET , function ( err , decoded ) {
240240 if ( err ) {
241- next ( err ) ;
241+ return next ( err ) ;
242242 } else {
243243 req . body . decodedToken = decoded ;
244- next ( ) ;
244+ return next ( ) ;
245245 }
246246 } ) ;
247247}
@@ -258,13 +258,13 @@ function parseAccountConfirmationToken(req, res, next) {
258258 if ( ! ! req . body . token ) {
259259 jwt . verify ( req . body . token , process . env . JWT_CONFIRM_ACC_SECRET , function ( err , decoded ) {
260260 if ( err ) {
261- next ( err ) ;
261+ return next ( err ) ;
262262 } else {
263263 req . body . decodedToken = decoded ;
264264 }
265265 } ) ;
266266 }
267- next ( ) ;
267+ return next ( ) ;
268268}
269269
270270/**
@@ -277,10 +277,10 @@ async function getAccountTypeFromConfirmationToken(req, res, next) {
277277 const confirmationObj = await Services . AccountConfirmation . findById ( req . body . decodedToken . accountConfirmationId ) ;
278278 if ( confirmationObj ) {
279279 req . body . accountType = confirmationObj . accountType ;
280- next ( ) ;
280+ return next ( ) ;
281281 } else {
282282 //Either the token was already used, it's invalid, or user does not exist.
283- next ( {
283+ return next ( {
284284 status : 401 ,
285285 message : Constants . Error . ACCOUNT_TOKEN_401_MESSAGE ,
286286 error : { }
@@ -299,10 +299,10 @@ async function validateResetToken(req, res, next) {
299299 const userObj = await Services . Account . findById ( req . body . decodedToken . accountId ) ;
300300 if ( resetObj && userObj ) {
301301 req . body . user = userObj ;
302- next ( ) ;
302+ return next ( ) ;
303303 } else {
304304 //Either the token was already used, it's invalid, or user does not exist.
305- next ( {
305+ return next ( {
306306 status : 401 ,
307307 message : Constants . Error . ACCOUNT_TOKEN_401_MESSAGE ,
308308 error : { }
@@ -324,10 +324,10 @@ async function validateConfirmationToken(req, res, next) {
324324 userObj . accountType = confirmationObj . accountType ;
325325 await Services . Account . updateOne ( confirmationObj . accountId , userObj ) ;
326326 req . body . user = userObj ;
327- next ( ) ;
327+ return next ( ) ;
328328 } else {
329329 //Either the token was already used, it's invalid, or user does not exist.
330- next ( {
330+ return next ( {
331331 status : 401 ,
332332 message : Constants . Error . ACCOUNT_TOKEN_401_MESSAGE ,
333333 error : { }
@@ -349,7 +349,7 @@ async function validateConfirmationTokenWithoutAccount(req, res, next) {
349349 req . body . accountDetails . accountType = confirmationObj . accountType ;
350350 }
351351 }
352- next ( ) ;
352+ return next ( ) ;
353353}
354354
355355
@@ -362,10 +362,10 @@ async function validateConfirmationTokenWithoutAccount(req, res, next) {
362362function deleteResetToken ( req , res , next ) {
363363 Services . ResetPasswordToken . deleteToken ( req . body . decodedToken . resetId ) . then (
364364 ( ) => {
365- next ( ) ;
365+ return next ( ) ;
366366 } ,
367367 ( err ) => {
368- next ( err ) ;
368+ return next ( err ) ;
369369 }
370370 ) ;
371371}
@@ -380,7 +380,7 @@ async function addCreationRoleBindings(req, res, next) {
380380 // Get the default role for the account type given
381381 const roleName = Constants . General . POST_ROLES [ req . body . account . accountType ] ;
382382 await Services . RoleBinding . createRoleBindingByRoleName ( req . body . account . id , roleName ) ;
383- next ( ) ;
383+ return next ( ) ;
384384}
385385
386386/**
@@ -390,7 +390,7 @@ async function addCreationRoleBindings(req, res, next) {
390390function createRoleBindings ( roleName = undefined ) {
391391 return async ( req , res , next ) => {
392392 await Services . RoleBinding . createRoleBindingByRoleName ( req . user . id , roleName ) ;
393- next ( ) ;
393+ return next ( ) ;
394394 }
395395}
396396
@@ -403,7 +403,7 @@ function createRoleBindings(roleName = undefined) {
403403async function addSponsorRoleBindings ( req , res , next ) {
404404 const account = Services . Account . findById ( req . body . sponsorDetails . accountId ) ;
405405 await Services . RoleBinding . createRoleBindingByRoleName ( account . id , account . accountType ) ;
406- next ( ) ;
406+ return next ( ) ;
407407}
408408
409409module . exports = {
0 commit comments