<commit_before>apos.define('apostrophe-users-editor-modal', {

  extend: 'apostrophe-pieces-editor-modal',

  construct: function(self, options) {

    var superBeforeShow = self.beforeShow;
    self.beforeShow = function(callback) {
      self.requirePasswordWhenCreating();
      return superBeforeShow(function(err) {
        if (err) {
          return callback(err);
        }
        self.enableTitleViaName();
        self.enableUsernameViaTitle();
        return callback(null);
      });
    };

    self.requirePasswordWhenCreating = function() {
      if (!self.options.create) {
        return;
      }
      self.schema = _.clone(self.schema);
      var password = _.find(self.schema, { name: 'password' });
      if (!password) {
        return;
      }
      password.required = true;
    };

    self.enableTitleViaName = function() {
      self.$title = apos.schemas.findField(self.$el, 'title');<commit_msg>fix bug that causes the password field to become "required" on edits that follow an add<commit_after>apos.define('apostrophe-users-editor-modal', {

  extend: 'apostrophe-pieces-editor-modal',

  construct: function(self, options) {

    var superBeforeShow = self.beforeShow;
    self.beforeShow = function(callback) {
      self.requirePasswordWhenCreating();
      return superBeforeShow(function(err) {
        if (err) {
          return callback(err);
        }
        self.enableTitleViaName();
        self.enableUsernameViaTitle();
        return callback(null);
      });
    };

    self.requirePasswordWhenCreating = function() {
      if (!self.options.create) {
        return;
      }

      // Clone deep enough that we can tamper with `required` without
      // affecting subsequent edit modals
      self.schema = _.map(self.schema, _.clone);

      var password = _.find(self.schema, { name: 'password' });
      if (!password) {
        return;
      }
      password.required = true;
    };

    self.enableTitleViaName = function() {
      self.$title = apos.schemas.findField(self.$el, 'title');
{'fraction_non_alphanumeric': 0.12616136919315404, 'fraction_numerical': 0.0, 'mean_word_length': 2.5894736842105264, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3951267', 'n_tokens_mistral': 601, 'n_tokens_neox': 578, 'n_words': 117}