function actHandlerNeedsDojoAdmin(cmd, param, type, msgDefault) {
    return function(request, reply) {
      // Note: request.user is set in onPostAuthHandler
      const user = request.user;
      if (!user) return reply(Boom.unauthorized('Not logged in'));

      let msg = {
        cmd: 'user_is_dojo_admin',
        role: 'cd-dojos',
        locality: server.methods.locality(request),
      };

      if (user) {
        msg = _.defaults(msg, user);
      } else if (request.user) {
        msg = _.defaults(msg, request.user);
      }

      if (request.payload) {
        msg = _.defaults(msg, request.payload);
      }
      if (request.query) {
        msg = _.defaults(msg, request.query);
      }

      if (param) {
        const paramsMsg = {};
        const params = _.isArray(param) ? param : [param];
        _.each(params, p => {
          if (request.params[p]) paramsMsg[p] = request.params[p];
        });
        msg = _.defaults(msg, paramsMsg);
      }

      request.seneca.act(msg, (err, resp) => {
        if (err) return reply(Boom.badImplementation());
        let isCDFAdmin = false;
        let code = 200;
        const roles = _.deepHas(user, 'user.roles')
          ? request.user.user.roles
          : [];
        if (_.includes(roles, 'cdf-admin')) {
          isCDFAdmin = true;
        }
        if (!resp.userIsDojoAdmin && !isCDFAdmin) {
          code = 401;
          return reply({
            ok: false,
            why:
              'You must be a dojo admin or ticketing admin to access this data',
          }).code(code);
        }
        return doAct(request, reply, cmd, param, user, type, msgDefault);
      });
    };
  }
// Check if the user is a dojo Admin OR a cdfAdmin
Check if the user is a dojo Admin OR a cdfAdmin
Check if the user is a dojo Admin OR a cdfAdmin
function actHandlerNeedsDojoAdmin(cmd, param, type, msgDefault) {
    return function(request, reply) {
      const user = request.user;
      if (!user) return reply(Boom.unauthorized('Not logged in'));
      let msg = {
        cmd: 'user_is_dojo_admin',
        role: 'cd-dojos',
        locality: server.methods.locality(request),
      };
      if (user) {
        msg = _.defaults(msg, user);
      } else if (request.user) {
        msg = _.defaults(msg, request.user);
      }
      if (request.payload) {
        msg = _.defaults(msg, request.payload);
      }
      if (request.query) {
        msg = _.defaults(msg, request.query);
      }
      if (param) {
        const paramsMsg = {};
        const params = _.isArray(param) ? param : [param];
        _.each(params, p => {
          if (request.params[p]) paramsMsg[p] = request.params[p];
        });
        msg = _.defaults(msg, paramsMsg);
      }
      request.seneca.act(msg, (err, resp) => {
        if (err) return reply(Boom.badImplementation());
        let isCDFAdmin = false;
        let code = 200;
        const roles = _.deepHas(user, 'user.roles')
          ? request.user.user.roles
          : [];
        if (_.includes(roles, 'cdf-admin')) {
          isCDFAdmin = true;
        }
        if (!resp.userIsDojoAdmin && !isCDFAdmin) {
          code = 401;
          return reply({
            ok: false,
            why:
              'You must be a dojo admin or ticketing admin to access this data',
          }).code(code);
        }
        return doAct(request, reply, cmd, param, user, type, msgDefault);
      });
    };
  }
function actHandlerNeedsDojoAdmin ( cmd , param , type , msgDefault ) { return function ( request , reply ) { const user = request . user ; if ( ! user ) return reply ( Boom . unauthorized ( 'Not logged in' ) ) ; let msg = { cmd : 'user_is_dojo_admin' , role : 'cd-dojos' , locality : server . methods . locality ( request ) , } ; if ( user ) { msg = _ . defaults ( msg , user ) ; } else if ( request . user ) { msg = _ . defaults ( msg , request . user ) ; } if ( request . payload ) { msg = _ . defaults ( msg , request . payload ) ; } if ( request . query ) { msg = _ . defaults ( msg , request . query ) ; } if ( param ) { const paramsMsg = { } ; const params = _ . isArray ( param ) ? param : [ param ] ; _ . each ( params , p => { if ( request . params [ p ] ) paramsMsg [ p ] = request . params [ p ] ; } ) ; msg = _ . defaults ( msg , paramsMsg ) ; } request . seneca . act ( msg , ( err , resp ) => { if ( err ) return reply ( Boom . badImplementation ( ) ) ; let isCDFAdmin = false ; let code = 200 ; const roles = _ . deepHas ( user , 'user.roles' ) ? request . user . user . roles : [ ] ; if ( _ . includes ( roles , 'cdf-admin' ) ) { isCDFAdmin = true ; } if ( ! resp . userIsDojoAdmin && ! isCDFAdmin ) { code = 401 ; return reply ( { ok : false , why : 'You must be a dojo admin or ticketing admin to access this data' , } ) . code ( code ) ; } return doAct ( request , reply , cmd , param , user , type , msgDefault ) ; } ) ; } ; }
Check if the user is a dojo Admin OR a cdfAdmin
Check if the user is a dojo Admin OR a cdfAdmin
// Note: request.user is set in onPostAuthHandler