<commit_before>define(["config", "app/app"], function(config, App) {
  "use strict";

  Ember.Application.initializer({
    name: 'session',
    after: "store",

    initialize: function(container, application) {
      application.deferReadiness()

      App.Session = Ember.Object.extend({
        resourceUrl: config.host + '/v1/users/whoami',
        currentUser: null,

        init: function() {
          this._super()

          var token = window.localStorage.getItem('authToken')
          this.set('authToken', token) // this won't trigger authTokenChanged
          this.set('signedIn', false)
          this.authTokenChanged()
        },

        reset: function() {
          this.set('authToken', null)
          this.set('currentUser', null)
          this.set('signedIn', false)
        },

        authTokenChanged: function() {
          var done = function(result) {
            var store = container.lookup('store:main')
            store.push('user', result.users)
            var user = store.find('user', result.users.id)

            this.set('currentUser', user)
            this.set('signedIn', true)

            application.advanceReadiness()
          }

          var error = function() {
            application.advanceReadiness()
          }

          window.localStorage.setItem('authToken', this.get('authToken'))

          if (this.get('authToken')
              && this.get('authToken').length > 0
              && this.get('authToken') != 'null')
            Ember.$.ajax({
              url: this.resourceUrl,
              context: this
            })<commit_msg>Resolves promise in Session before assigning it to currentUser<commit_after>define(["config", "app/app"], function(config, App) {
  "use strict";

  Ember.Application.initializer({
    name: 'session',
    after: "store",

    initialize: function(container, application) {
      application.deferReadiness()

      App.Session = Ember.Object.extend({
        resourceUrl: config.host + '/v1/users/whoami',
        currentUser: null,

        init: function() {
          this._super()

          var token = window.localStorage.getItem('authToken')
          this.set('authToken', token) // this won't trigger authTokenChanged
          this.set('signedIn', false)
          this.authTokenChanged()
        },

        reset: function() {
          this.set('authToken', null)
          this.set('currentUser', null)
          this.set('signedIn', false)
        },

        authTokenChanged: function() {
          var done = function(result) {
            var store = container.lookup('store:main')
            store.push('user', result.users)
            store.find('user', result.users.id)
              .then(function(user) {
                this.set('currentUser', user)
              }.bind(this))

            this.set('signedIn', true)

            application.advanceReadiness()
          }

          var error = function() {
            application.advanceReadiness()
          }

          window.localStorage.setItem('authToken', this.get('authToken'))

          if (this.get('authToken')
              && this.get('authToken').length > 0
              && this.get('authToken') != 'null')
            Ember.$.ajax({
              url: this.resourceUrl,
              context: this
            })
{'fraction_non_alphanumeric': 0.13544494720965308, 'fraction_numerical': 0.0012066365007541479, 'mean_word_length': 1.9215859030837004, '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': '6872127', 'n_tokens_mistral': 900, 'n_tokens_neox': 870, 'n_words': 170}