title: Where am i going wrong with using promise inside class?
body: <p>i am using the class as follows</p>
  
  <pre><code>var user_class = function (body) {
      this.body = body;
  };
  
  user_class.prototype.login = function () {
      var that = this;
      return new Promise((fullfill,reject)=&gt;{
          that.find_by_username()
              .then(that.user_exists)
              .then(that.check_credentials)
              .then(that.generate_token)
              .then(fullfill)
              .catch(reject);
      });
  };
  
  user_class.prototype.find_by_username = function () {
      var that = this;
      return new Promise((fullfill,reject)=&gt;{
          user_model
              .find({username: that.body.username})
              .then((user)=&gt;{
                  that.user = user;
              })
              .then(fullfill)
              .catch(reject);
      });
  };
  
  user_class.prototype.user_exists = function () {
      var that = this;
      return new Promise((fullfill,reject)=&gt;{
          console.log(that.user);
          if(that.user !== undefined) {
              fullfill();
          }else{
              reject(new Error('null user'));
          }
      });
  };
  </code></pre>
  
  <p>The problem is when i call the <code>login</code> method, the <code>find_by_username</code> function works just fine and the user us set properly which i validated from <code>console.log</code> on <code>that.user</code> . but the <code>user_exits</code> method throws error which means it is finding that the <code>user</code> is set to undefined. I already refered to <code>this</code> to <code>that</code> and still not working. </p>
  
  <p>Can someone please explain what is wrong with my logic and why the user is not being set to object ?</p>