<commit_before>module.exports = function(Promise, Service, AccountModel, config, UserService, _) {
  return Service.extend({

    model: AccountModel,

    create: function(values, queryOptions) {
      var createAccount = this._super;

      queryOptions  = queryOptions || {};

      values.name   = values.firstName + ' ' + values.lastName;
      values.active = !config[ 'clever-accounts' ].requireConfirmation ? true : false;

      if (values.subDomain) {
        values.subDomain = values.subDomain;
      } else if (values.domain) {
        values.subDomain = values.domain.replace('http://', '').replace('www.', '').split('.')[0];
      }

      return new Promise(function(resolve, reject) {
        var account;

        this
          .transaction(queryOptions)
          .then(this.callback(function() {
            return createAccount.apply(this, [values, queryOptions]);
          }))
          .then(function(_account) {
            account = _account
            var userData = _.extend({}, {
              AccountId     : account.id,
              title         : values.title || null,
              firstName     : values.firstName,
              lastName      : values.lastName,
              email         : values.email,
              username      : values.username || values.email,
              password      : <PASSWORD>,
              phone         : values.phone || null,

              active        : true,
              confirmed     : config['clever-accounts'].emailConfirmation === true ? false : true,

              hasAdminRight : false
            });

            if (account.Roles && account.Roles.length) {
              userData.Role = account.Roles[0];
            }

            return UserService.create(userData, queryOptions);
          })
          .then(function(user) {
            return queryOptions.transaction.commit();
          })
          .then(function() {
            resolve(account);
          })
          .catch(function(err) {<commit_msg>fix(account): Service allows overrides to confirmed when applicable<commit_after>module.exports = function(Promise, Service, AccountModel, config, UserService, _) {
  return Service.extend({

    model: AccountModel,

    create: function(values, queryOptions) {
      var createAccount = this._super;

      queryOptions  = queryOptions || {};

      values.name   = values.firstName + ' ' + values.lastName;
      values.active = !config[ 'clever-accounts' ].requireConfirmation ? true : false;

      if (values.subDomain) {
        values.subDomain = values.subDomain;
      } else if (values.domain) {
        values.subDomain = values.domain.replace('http://', '').replace('www.', '').split('.')[0];
      }

      return new Promise(function(resolve, reject) {
        var account;

        this
          .transaction(queryOptions)
          .then(this.callback(function() {
            return createAccount.apply(this, [values, queryOptions]);
          }))
          .then(function(_account) {
            account = _account
            var userData = _.extend({}, {
              AccountId     : account.id,
              title         : values.title || null,
              firstName     : values.firstName,
              lastName      : values.lastName,
              email         : values.email,
              username      : values.username || values.email,
              password      : <PASSWORD>,
              phone         : values.phone || null,

              active        : true,
              confirmed     : values.confirmed !== undefined ? values.confirmed : (config['clever-accounts'].emailConfirmation === true ? false : true),

              hasAdminRight : false
            });

            if (account.Roles && account.Roles.length) {
              userData.Role = account.Roles[0];
            }

            return UserService.create(userData, queryOptions);
          })
          .then(function(user) {
            return queryOptions.transaction.commit();
          })
          .then(function() {
            resolve(account);
          })
          .catch(function(err) {
{'fraction_non_alphanumeric': 0.11910549343704424, 'fraction_numerical': 0.0009722897423432182, 'mean_word_length': 1.7433333333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3071280', 'n_tokens_mistral': 1049, 'n_tokens_neox': 1022, 'n_words': 208}