title: Ember RSVP Promise resolve always returns undefined value
body: <p>I'm using Ember-simple-auth and trying to return data from my custom authenticator back into the controller that did the authenticating.</p>
  
  <p>in my authenticator/custom.js:</p>
  
  <pre><code>  authenticate(identification, password) {
        return  new Ember.RSVP.Promise(function (resolve, reject) {
            var loginURL = 'https://domain.com/login';    
            var authObj = Ember.Object.create({"identity":identification,"password":password});
            var hash = authObj.getProperties('identity', 'password');
            var stringHash = JSON.stringify(hash);
  
                var xhr = new XMLHttpRequest();
                xhr.open("post", loginURL);
                xhr.onreadystatechange = handler;
                xhr.responseType = 'json';
                xhr.setRequestHeader('Content-Type', 'application/json');
                xhr.setRequestHeader('Format', 'JSON');
                xhr.send(stringHash);
  
                function handler() {
                  if (this.readyState === this.DONE) {
                    if (this.status === 200) {
                      console.log('response is: ',this.response); /// &lt;-- returns good response data
                      resolve(this.response);
                    } else {
                        reject( 'failed with status: [' + this.status + ']');
  
                    }
                  }
              }
  </code></pre>
  
  <p>and in my login controller:</p>
  
  <pre><code> authenticate() {
    let { identification, password } = this.getProperties('identification', 'password');
  
    var session = this.get('session');
    session.authenticate('authenticator:custom', identification, password).then((reason) =&gt; {
              console.log('failed login',reason);
          });   
      }
  },
  </code></pre>
  
  <p>But I'd really like to be able to handle the <code>resolve</code> function and get it's <code>value</code> payload from the <code>authenticate</code> promise.</p>
  
  <p>If I change the <code>.catch</code> to a <code>.then</code> the response function is successfully called but always has an undefined value as its payload:</p>
  
  <pre><code>  session.authenticate('authenticator:custom', identification, password).then(
        (response) =&gt; {
            console.log('response: ',response); //// &lt;---- always 'undefined'
              this.setUserWithData(response);
          },
        (reason) =&gt; {
              this.set('Login failed: ',reason);
          }       
  
      );    
      }
  </code></pre>
  
  <p>Even if I restructure the promise, rearrange how the function is called, the first function from an RSVP is successfully called, but has an undefined payload.  The second function from an RSVP always has a correct payload.</p>
  
  <p>I tried reversing the resolve/reject:</p>
  
  <pre><code>Ember.RSVP.Promise(function (resolve, reject){
  </code></pre>
  
  <p>to</p>
  
  <pre><code>Ember.RSVP.Promise(function (reject, resolve){
  </code></pre>
  
  <p>and the function successfully carries the response, but the simple-auth now believes it has failed its authorization.</p>
  
  <p>I'd like to be able to pass the response payload into my controller.  Or, if that can't be done, how can I inject data from the response into my session and ember-data store?  It didn't seem like good practice to call and insert data into the store from within the authenticate function of the authenticator.</p>