How to use the ms.onBehalfOf function in ms

To help you get started, we’ve selected a few ms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / opensource-portal / routes / api / createRepo.ts View on Github external
'ms.justification',
    'ms.notify',
    'ms.teams',
    'ms.template',
    'ms.project-type',
  ];
  const properties = {};
  const parameters = bodyOverride || req.body;
  ourFields.forEach((fieldName) => {
    if (parameters[fieldName] !== undefined) {
      properties[fieldName] = parameters[fieldName];
      delete parameters[fieldName];
    }
  });
  const msProperties = {
    onBehalfOf: properties['ms.onBehalfOf'] || req.headers['ms-onbehalfof'],
    justification: properties['ms.justification'] || req.headers['ms-justification'],
    license: properties['ms.license'] || req.headers['ms-license'],
    approvalType: properties['ms.approval'] || req.headers['ms-approval'],
    approvalUrl: properties['ms.approval-url'] || req.headers['ms-approval-url'],
    notify: properties['ms.notify'] || req.headers['ms-notify'],
    teams: properties['ms.teams'] || req.headers['ms-teams'],
    template: properties['ms.template'] || req.headers['ms-template'],
    projectType: properties['ms.project-type'] || req.headers['ms-project-type'],
  };
  // Validate licenses
  let msLicense = msProperties.license;
  if (!msLicense) {
    throw jsonError(new Error('Missing Microsoft license information'), 422);
  }
  msLicense = msLicense.toLowerCase();
  if (supportedLicenseExpressions.indexOf(msLicense) < 0) {
github microsoft / opensource-portal / routes / api / client / newOrgRepo.ts View on Github external
router.post('/repo/:repo', asyncHandler(discoverUserIdentities), asyncHandler(async function (req: ILocalApiRequest, res, next) {
  const config = req.app.settings.runtimeConfig;
  const organization = req.organization as Organization;
  if (organization.createRepositoriesOnGitHub) {
    return next(jsonError(`The GitHub organization ${organization.name} is configured as "createRepositoriesOnGitHub": repos should be created on GitHub.com directly and not through this wizard.`, 400));
  }
  const body = req.body;
  if (!body) {
    return next(jsonError('No body', 400));
  }
  req.apiVersion = req.query['api-version'] || req.headers['api-version'] || '2017-07-27';
  if (req.apiContext && req.apiContext.getGitHubIdentity()) {
    body['ms.onBehalfOf'] = req.apiContext.getGitHubIdentity().username;
  }
  // these fields do not need translation: name, description, private
  const approvalTypesToIds = config.github.approvalTypes.fields.approvalTypesToIds;
  if (!approvalTypesToIds[body.approvalType]) {
    return next(jsonError('The approval type is not supported or approved at this time', 400));
  }
  body.approvalType = approvalTypesToIds[body.approvalType];
  translateValue(body, 'approvalType', 'ms.approval');
  translateValue(body, 'approvalUrl', 'ms.approval-url');
  translateValue(body, 'justification', 'ms.justification');
  translateValue(body, 'legalEntity', 'ms.entity');
  translateValue(body, 'projectType', 'ms.project-type');
  // Team permissions
  if (!body.selectedAdminTeams || !body.selectedAdminTeams.length) {
    return next(jsonError('No administration team(s) provided in the request', 400));
  }

ms

Tiny millisecond conversion utility

MIT
Latest version published 4 years ago

Package Health Score

76 / 100
Full package analysis