<commit_before>import Ember from 'ember';
import Base from 'simple-auth/authenticators/base';
import ENV from "../config/environment";


export default Base.extend({
  tokenEndpoint: ENV.APP.API_HOST + '/sessions/create',
  restore: function(data) {
    return new Ember.RSVP.Promise(function (resolve, reject) {
      if (!Ember.isEmpty(data.token)) {
        resolve(data);
      }
      else {
        reject();
      }
    });
  },

  authenticate: function(options) { 
    var self = this;
    return new Ember.RSVP.Promise(function(resolve, reject) { 
    Ember.$.ajax({ 
      url: self.tokenEndpoint, 
      type: 'POST', 
      data: JSON.stringify({
          email: options.identification,
          password: <PASSWORD>
      }),
      contentType: 'application/json;charset=utf-8',
      dataType: 'json' 
    }).then(function(response) { 
      Ember.run(function() { 
        resolve({ token: response.id_token }); 
      }); 
    }, function(xhr) { 
      var response = JSON.parse(xhr.responseText); 
      Ember.run(function() { 
        reject(response.error); 
      }); 
    }); 
  }); 
}, 

  invalidate: function() {
    console.log('invalidate...');
    return Ember.RSVP.resolve();
  }
});
<commit_msg>Properly display login errors<commit_after>import Ember from 'ember';
import Base from 'simple-auth/authenticators/base';
import ENV from "../config/environment";


export default Base.extend({
  tokenEndpoint: ENV.APP.API_HOST + '/sessions/create',
  restore: function(data) {
    return new Ember.RSVP.Promise(function (resolve, reject) {
      if (!Ember.isEmpty(data.token)) {
        resolve(data);
      }
      else {
        reject();
      }
    });
  },

  authenticate: function(options) { 
    var self = this;
    return new Ember.RSVP.Promise(function(resolve, reject) { 
    Ember.$.ajax({ 
      url: self.tokenEndpoint, 
      type: 'POST', 
      data: JSON.stringify({
          email: options.identification,
          password: <PASSWORD>
      }),
      contentType: 'application/json;charset=utf-8',
      dataType: 'json' 
    }).then(function(response) { 
      Ember.run(function() { 
        resolve({ token: response.id_token }); 
      }); 
    }, function(xhr) { 
      var response = JSON.parse(xhr.responseText); 
      Ember.run(function() { 
        reject(response.errors[0].detail);
      }); 
    }); 
  }); 
}, 

  invalidate: function() {
    console.log('invalidate...');
    return Ember.RSVP.resolve();
  }
});

{'fraction_non_alphanumeric': 0.1528225806451613, 'fraction_numerical': 0.0012096774193548388, 'mean_word_length': 2.484550561797753, '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': '4412174', 'n_tokens_mistral': 797, 'n_tokens_neox': 751, 'n_words': 143}