<commit_before>module.exports = Zeppelin.Model.extend({
  name: 'User',

  defaults: {
    signup_step: 1
  },

  localAttributes: ['signup_step', 'passwordReset'],

  requestSignup: function() {
    return Boards.Connection.post('/api/auth/signup_request/', {
      email: this.get('email')
    });
  },

  setEmailFromJWT: function(token) {
    var tokenData;

    token = token || '';
    token = token.replace(/^=/, '');
    tokenData = _.decodeJWT(token);

    if (tokenData.email) {
      this.set({
        'email': tokenData.email,
        'signup_request_token': token
      });
    }

    return this;
  },

  isWaitingForEmailValidation: function() {
    return this.has('email') && this.get('signup_step') === 2;
  },

  updateSignupStep: function(step) {
    this.set('signup_step', step).saveCache();
    return this;
  },

  validateSignupEmailDomain: function(domains) {
    return Boards.Connection.post('/api/auth/signup_domains/validate/', {
      signup_domains: domains
    });
  },

  hasInviteDomains: function() {
    return this.has('signup_domains') && this.get('signup_domains').length > 0;
  },

  validateUsername: function() {
    return Boards.Connection.post('/api/auth/username/validate/', {
      username: this.get('username')
    });
  },

  signup: function(user) {
    user = user || this.toJSON();
    return Boards.Connection.post('/api/auth/signup/', user);
  },

  signin: function(user) {
    user = user || this.toJSON();
    return Boards.Connection.post('/api/auth/signin/', user);
  },

  signout: function() {
    this.clear();
    this.cache.clearAll();
    return this;
  },

  isSignedIn: function() {
    return this.has('token');
  },

  forgotPassword: function(email) {
    email = email || this.get('email');
    return Boards.Connection.post('/api/auth/forgot_password/', {email: email});
  },

  setPasswordResetDataFromJWT: function(token) {
    var tokenData;

    token = token || '';
    token = token.replace(/^=/, '');
    tokenData = _.decodeJWT(token);

    if (tokenData.type === 'PasswordReset') {
      this.set({
        passwordResetData: {
          id: tokenData.id,
          type: tokenData.type,
          token: token,
          version: tokenData.token_version
        }
      }).saveCache();
    }

    return this;
  },

  canResetPassword: function() {
    var reset = this.get('passwordResetData');
    return reset && reset.token && reset.type === 'PasswordReset';
  },

  resetPassword: function(password) {
    if (this.canResetPassword() && password) {
      return Boards.Connection.post('/api/auth/reset_password/', {
        token: this.get('passwordResetData').token,
        password: password
      });
    }
  },

  fetchAccounts: function() {
    Boards.Connection.get('/api/accounts/', this.get('token')).done(function(accounts) {
      this.set('accounts', accounts);
      this.publish('user:accounts:fetched', accounts);
    }.bind(this)).fail(function(error) {
      this.publish('user:accounts:fetched', error);
    }.bind(this));
  },

  accounts: function() {
    var accounts = [];

    _.forEach(this.get('accounts'), function(account) {
      accounts.push({
        url: '/' + account.slug + '/',
        name: account.name,
        image: account.image_url ? account.image_url : '/default/'
      });
    });

    return accounts;
  },

  isInAccount: function(slug) {
    if (slug) {
      return _.find(this.get('accounts'), {slug: slug}) !== undefined;
    } else {
      return false;
    }
  }
});
<commit_msg>Remove unused User.fetchAccounts method.<commit_after>module.exports = Zeppelin.Model.extend({
  name: 'User',

  defaults: {
    signup_step: 1
  },

  localAttributes: ['signup_step', 'passwordReset'],

  requestSignup: function() {
    return Boards.Connection.post('/api/auth/signup_request/', {
      email: this.get('email')
    });
  },

  setEmailFromJWT: function(token) {
    var tokenData;

    token = token || '';
    token = token.replace(/^=/, '');
    tokenData = _.decodeJWT(token);

    if (tokenData.email) {
      this.set({
        'email': tokenData.email,
        'signup_request_token': token
      });
    }

    return this;
  },

  isWaitingForEmailValidation: function() {
    return this.has('email') && this.get('signup_step') === 2;
  },

  updateSignupStep: function(step) {
    this.set('signup_step', step).saveCache();
    return this;
  },

  validateSignupEmailDomain: function(domains) {
    return Boards.Connection.post('/api/auth/signup_domains/validate/', {
      signup_domains: domains
    });
  },

  hasInviteDomains: function() {
    return this.has('signup_domains') && this.get('signup_domains').length > 0;
  },

  validateUsername: function() {
    return Boards.Connection.post('/api/auth/username/validate/', {
      username: this.get('username')
    });
  },

  signup: function(user) {
    user = user || this.toJSON();
    return Boards.Connection.post('/api/auth/signup/', user);
  },

  signin: function(user) {
    user = user || this.toJSON();
    return Boards.Connection.post('/api/auth/signin/', user);
  },

  signout: function() {
    this.clear();
    this.cache.clearAll();
    return this;
  },

  isSignedIn: function() {
    return this.has('token');
  },

  forgotPassword: function(email) {
    email = email || this.get('email');
    return Boards.Connection.post('/api/auth/forgot_password/', {email: email});
  },

  setPasswordResetDataFromJWT: function(token) {
    var tokenData;

    token = token || '';
    token = token.replace(/^=/, '');
    tokenData = _.decodeJWT(token);

    if (tokenData.type === 'PasswordReset') {
      this.set({
        passwordResetData: {
          id: tokenData.id,
          type: tokenData.type,
          token: token,
          version: tokenData.token_version
        }
      }).saveCache();
    }

    return this;
  },

  canResetPassword: function() {
    var reset = this.get('passwordResetData');
    return reset && reset.token && reset.type === 'PasswordReset';
  },

  resetPassword: function(password) {
    if (this.canResetPassword() && password) {
      return Boards.Connection.post('/api/auth/reset_password/', {
        token: this.get('passwordResetData').token,
        password: password
      });
    }
  },

  accounts: function() {
    var accounts = [];

    _.forEach(this.get('accounts'), function(account) {
      accounts.push({
        url: '/' + account.slug + '/',
        name: account.name,
        image: account.image_url ? account.image_url : '/default/'
      });
    });

    return accounts;
  },

  isInAccount: function(slug) {
    if (slug) {
      return _.find(this.get('accounts'), {slug: slug}) !== undefined;
    } else {
      return false;
    }
  }
});

{'fraction_non_alphanumeric': 0.16777926123720516, 'fraction_numerical': 0.0008900756564307966, 'mean_word_length': 2.804740406320542, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7203764', 'n_tokens_mistral': 2190, 'n_tokens_neox': 2127, 'n_words': 367}