<commit_before>import Ember from 'ember';
import Base from 'simple-auth/authenticators/base';

/**
 * Custom ember-simple-auth authenticator to support firebase login
 */
export default Base.extend({

  restore: function(data) {
    var ref = this.get('firebase');
    return new Ember.RSVP.Promise(function(resolve, reject) {
      var authData = ref.getAuth();
      if (authData) {
        resolve(data);
      } else {
        reject(data);
      }
    });
  },

  authenticate: function(options) {
    var ref = this.get('firebase');
    return new Ember.RSVP.Promise(function(resolve, reject) {
      ref.authWithPassword({
        email: options.email,
        password: <PASSWORD>.password
      }, function(error, authData) {
        if (error) {
          reject(error);
        } else {
          resolve(authData);
        }
      });<commit_msg>Authenticate firebase client if a different tab logs in<commit_after>import Ember from 'ember';
import Base from 'simple-auth/authenticators/base';

/**
 * Custom ember-simple-auth authenticator to support firebase login
 */
export default Base.extend({

  restore: function(data) {
    var _this = this;
    var ref = this.get('firebase');

    return new Ember.RSVP.Promise(function(resolve, reject) {
      var authData = ref.getAuth();

      if(!data.token) return reject();
      if(authData) return resolve(data);

      ref.authWithCustomToken(data.token, function(error, authData){
        if(error) reject(error);
        resolve(authData);
      });
    });
  },

  authenticate: function(options) {
    var ref = this.get('firebase');
    return new Ember.RSVP.Promise(function(resolve, reject) {
      ref.authWithPassword({
        email: options.email,
        password: <PASSWORD>.password
      }, function(error, authData) {
        if (error) {
          reject(error);
        } else {
          resolve(authData);
        }
      });
{'fraction_non_alphanumeric': 0.12813807531380753, 'fraction_numerical': 0.0, 'mean_word_length': 2.6577437858508604, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4869668', 'n_tokens_mistral': 566, 'n_tokens_neox': 554, 'n_words': 130}