function actHandlerNeedsUser(cmd, param, opts, msgDefault) {
    return function(request, reply) {
      // Note: request.user is set in onPostAuthHandler
      const user = request.user;
      if (!user) {
        if (!opts || (opts && !opts.soft)) {
          return reply(Boom.unauthorized('Not logged in'));
        }
      }

      if (opts && opts.checkCdfAdmin === true) {
        const roles = _.deepHas(user, 'user.roles') ? user.user.roles : [];
        if (!_.includes(roles, 'cdf-admin')) {
          // Note: a 200 status code is still returned here (should be 403 by right)
          return reply({
            ok: false,
            why: 'You must be a cdf admin to access this data',
          });
        }
      }

      if (opts && opts.isOwn === true) {
        const requestedId = request.params[param];
        if (user.user.id !== requestedId) {
          // Note: a 200 status code is still returned here (should be 403 by right)
          return reply({
            ok: false,
            why:
              'You do not have sufficient permissions to access this feature',
          });
        }
      }

      return doAct(
        request,
        reply,
        cmd,
        param,
        user,
        opts && opts.type ? opts.type : null,
        msgDefault
      );
    };
  }
// If the act is having a specific rule on check_permissions, it needs to use this handler
If the act is having a specific rule on check_permissions, it needs to use this handler
If the act is having a specific rule on check_permissions it needs to use this handler
function actHandlerNeedsUser(cmd, param, opts, msgDefault) {
    return function(request, reply) {
      const user = request.user;
      if (!user) {
        if (!opts || (opts && !opts.soft)) {
          return reply(Boom.unauthorized('Not logged in'));
        }
      }
      if (opts && opts.checkCdfAdmin === true) {
        const roles = _.deepHas(user, 'user.roles') ? user.user.roles : [];
        if (!_.includes(roles, 'cdf-admin')) {
          return reply({
            ok: false,
            why: 'You must be a cdf admin to access this data',
          });
        }
      }
      if (opts && opts.isOwn === true) {
        const requestedId = request.params[param];
        if (user.user.id !== requestedId) {
          return reply({
            ok: false,
            why:
              'You do not have sufficient permissions to access this feature',
          });
        }
      }
      return doAct(
        request,
        reply,
        cmd,
        param,
        user,
        opts && opts.type ? opts.type : null,
        msgDefault
      );
    };
  }
function actHandlerNeedsUser ( cmd , param , opts , msgDefault ) { return function ( request , reply ) { const user = request . user ; if ( ! user ) { if ( ! opts || ( opts && ! opts . soft ) ) { return reply ( Boom . unauthorized ( 'Not logged in' ) ) ; } } if ( opts && opts . checkCdfAdmin === true ) { const roles = _ . deepHas ( user , 'user.roles' ) ? user . user . roles : [ ] ; if ( ! _ . includes ( roles , 'cdf-admin' ) ) { return reply ( { ok : false , why : 'You must be a cdf admin to access this data' , } ) ; } } if ( opts && opts . isOwn === true ) { const requestedId = request . params [ param ] ; if ( user . user . id !== requestedId ) { return reply ( { ok : false , why : 'You do not have sufficient permissions to access this feature' , } ) ; } } return doAct ( request , reply , cmd , param , user , opts && opts . type ? opts . type : null , msgDefault ) ; } ; }
If the act is having a specific rule on check_permissions, it needs to use this handler
If the act is having a specific rule on check_permissions it needs to use this handler
// Note: request.user is set in onPostAuthHandler // Note: a 200 status code is still returned here (should be 403 by right) // Note: a 200 status code is still returned here (should be 403 by right)