{"size": 1214, "ext": "js", "max_stars_repo_path": "server/methods/templates/updateTemplate.js", "max_stars_repo_name": "kmcroft13/cloud-templates", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/methods/templates/updateTemplate.js", "max_issues_repo_name": "kmcroft13/cloud-templates", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/methods/templates/updateTemplate.js", "max_forks_repo_name": "kmcroft13/cloud-templates", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.35, "max_line_length": 99, "alphanum_fraction": 0.647446458}
Meteor.methods({

  'updateTemplateInfo'(templateId, templateName, templateDescription, activeStatus) {
    console.log("### BEGIN updateTemplateInfo METHOD ###");
    check(templateId, Match.Any);
    check(templateName, Match.Any);
    check(templateDescription, Match.Any);
    check(activeStatus, Match.Any);

    const templateObject = Template.findOne(templateId);

    if (templateObject.owner != Meteor.userId()) {
      console.log(`ERROR: Could not update template ${templateId} because requestor was not owner`)
      throw new Meteor.Error(401, "This user is not authorized to complete this request");
    }

    Template.update(templateId, { $set: { 
        name: templateName,
        description: templateDescription,
        active: activeStatus 
    } });


    console.log(JSON.stringify({
        resource: "template",
        action: "update",
        callingMethod: "updateTemplateInfo",
        details: {
          id: templateId,
          name: templateName,
          description: templateDescription,
          active: activeStatus
        },
        requester: Meteor.userId()
    }));

    console.log("### END updateTemplateInfo METHOD ###");
  } //End updateTemplateInfo method
});
