<commit_before>import Ember from 'ember';
import OAuth2 from 'ember-oauth2';

export default Ember.Object.extend({
  init: function() {
    this._super();
    if (this.get('providerId')) {
      this.set('auth', OAuth2.create({providerId: this.get('providerId')}));
    }
  },

  provider: Ember.computed('auth', {
    /*jshint unused: false*/
    get(key) {
      return this.get('auth');
    },
    set(key, value) {
      this.set('providerId', value);
      // check if the value is falsey ie: most likely set to null
      if (value) {
        this.set('auth', OAuth2.create({providerId: value}));
      } else {
        this.set('auth', value);
      }
    }
  }),

  isExpired: Ember.computed('auth', {
    /*jshint unused: false*/
    get(key) {
      if (this.get('auth')) {
        return this.get('auth').accessTokenIsExpired();
      } else {
        return true;
      }
    }
  }),

  isNotExpired: Ember.computed('isExpired', {
    /*jshint unused: false*/
    get(key) {
      return !this.get('isExpired');
    }
  }),

  token: Ember.computed('auth', {
    /*jshint unused: false*/
    get(key) {
      return this.get('auth') ? this.get('auth').getToken() : null;
    }
  }),

  accessToken: Ember.computed('auth', {
    /*jshint unused: false*/
    get(key) {
      return this.get('auth') ? this.get('auth').getAccessToken() : false;
    }
  }),

  authorize: function() {
    var self = this;
    return new Ember.RSVP.Promise(function(resolve, reject) {
      var response = self.auth.authorize();
      var res = response ? resolve(response) : reject(response);
      return res;
    });
  },

  signout: function() {
    if (this.get('auth')) {
      this.auth.removeToken();
      this.set('auth', null);
      this.set('providerId', null);
    } else {
      return null;
    }
  }

});<commit_msg>session model authorize returns promise from oauth2 authorize<commit_after>import Ember from 'ember';
import OAuth2 from 'ember-oauth2';

export default Ember.Object.extend({
  init: function() {
    this._super();
    if (this.get('providerId')) {
      this.set('auth', OAuth2.create({providerId: this.get('providerId')}));
    }
  },

  provider: Ember.computed('auth', {
    /*jshint unused: false*/
    get(key) {
      return this.get('auth');
    },
    set(key, value) {
      this.set('providerId', value);
      // check if the value is falsey ie: most likely set to null
      if (value) {
        this.set('auth', OAuth2.create({providerId: value}));
      } else {
        this.set('auth', value);
      }
    }
  }),

  isExpired: Ember.computed('auth', {
    /*jshint unused: false*/
    get(key) {
      if (this.get('auth')) {
        return this.get('auth').accessTokenIsExpired();
      } else {
        return true;
      }
    }
  }),

  isNotExpired: Ember.computed('isExpired', {
    /*jshint unused: false*/
    get(key) {
      return !this.get('isExpired');
    }
  }),

  token: Ember.computed('auth', {
    /*jshint unused: false*/
    get(key) {
      return this.get('auth') ? this.get('auth').getToken() : null;
    }
  }),

  accessToken: Ember.computed('auth', {
    /*jshint unused: false*/
    get(key) {
      return this.get('auth') ? this.get('auth').getAccessToken() : false;
    }
  }),

  authorize: function() {
    return this.auth.authorize();
  },

  signout: function() {
    if (this.get('auth')) {
      this.auth.removeToken();
      this.set('auth', null);
      this.set('providerId', null);
    } else {
      return null;
    }
  }

});
{'fraction_non_alphanumeric': 0.17928286852589642, 'fraction_numerical': 0.0025611838360842347, 'mean_word_length': 2.500996015936255, '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': '2936346', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1187, 'n_words': 238}