function ensureAdmin(req, res, next) {
  model.User.find({
    where: {
      id: req.user,
      isAdmin: true,
    },
  }).then((user) => {
    if (!user) {
      const err = new Error();
      err.status = 401;
      err.message = 'You need to be an admin to access this endpoint';
      return next(err);
    }
    next();
  }).catch(err => next(err));
}
/**
 * Middleware function to check that the user is an Admin (deprecated)
 * todo(mziccard) Remove after replacing everywhere with checkScopes
 */
Middleware function to check that the user is an Admin (deprecated)
todo(mziccard) Remove after replacing everywhere with checkScopes
Middleware function to check that the user is an Admin ( deprecated ) todo ( mziccard ) Remove after replacing everywhere with checkScopes
function ensureAdmin(req, res, next) {
  model.User.find({
    where: {
      id: req.user,
      isAdmin: true,
    },
  }).then((user) => {
    if (!user) {
      const err = new Error();
      err.status = 401;
      err.message = 'You need to be an admin to access this endpoint';
      return next(err);
    }
    next();
  }).catch(err => next(err));
}
function ensureAdmin ( req , res , next ) { model . User . find ( { where : { id : req . user , isAdmin : true , } , } ) . then ( ( user ) => { if ( ! user ) { const err = new Error ( ) ; err . status = 401 ; err . message = 'You need to be an admin to access this endpoint' ; return next ( err ) ; } next ( ) ; } ) . catch ( err => next ( err ) ) ; }
Middleware function to check that the user is an Admin (deprecated)
 todo(mziccard) Remove after replacing everywhere with checkScopes
Middleware function to check that the user is an Admin ( deprecated ) todo ( mziccard ) Remove after replacing everywhere with checkScopes