nl_tokens: getProject Middleware assumes two url parameters : org and : repo and req . user checks user access level and sets the following properties on the request object . req . project = the project req . accessLevel = - 1 for no access 0 for public 1 for normal 2 for admin Errors : 404 : not found 401 : not public and you don t have access 500 : something strange happened w / the DB lookup
pl_tokens: function project ( req , res , next ) { if ( req . params . org === 'auth' ) { return next ( ) ; } anonProject ( req , res , function ( ) { if ( req . accessLevel > - 1 ) { return next ( ) ; } if ( ! req . user ) { req . session . return_to = req . url ; return <mask> . redirect ( '/login' ) ; } res . status ( 401 ) . send ( 'Not authorized' ) ; } ) ; }