auth/auth.service.js
/**
 * Check if user has the required minimun role.
 */
Check if user has the required minimun role.
Check if user has the required minimun role .
function hasRole(roleRequired){
    if(!roleRequired){throw new Error('Required role needs to be set');}
    return compose()
        .use(isAuthenticated())
        .use(function meetsRequirements(req,res,next){
            if(config.roles.indexOf(req.user.role)>=config.roles.indexOf(roleRequired)){
                return next();
            }else{
                return res.status(403).send('Forbidden');
            }
        })
}
function hasRole ( roleRequired ) { if ( ! roleRequired ) { throw new Error ( 'Required role needs to be set' ) ; } return compose ( ) . use ( isAuthenticated ( ) ) . use ( function meetsRequirements ( req , res , next ) { if ( config . roles . indexOf ( req . user . role ) >= config . roles . indexOf ( roleRequired ) ) { return next ( ) ; } else { return res . status ( 403 ) . send ( 'Forbidden' ) ; } } ) }
Check if user has the required minimun role.
Check if user has the required minimun role .