1

I am getting the [object,Object ] in my server terminal instead of whole user data . I do not know what does that mean... I think I did all perfectly but still unable to get the whole data. I specified of sailjs server. How to get whole user data instead of [object,Object]?

module.exports = {
  /**
   * Check the provided email address and password, and if they
   * match a real user in the database, sign in to Medool.
   */
  login: function (req, res) {

    // Try to look up user using the provided email address
    User.findOne({
      email: req.param('email')
    }, function foundUser(err, user) {

      if (err)
        return res.negotiate(err);
      if (!user)
        return res.notFound();

      // Compare password attempt from the form params to the encrypted password
      // from the database (`user.password`)
      require('machinepack-passwords').checkPassword({
        passwordAttempt: req.param('password'),
        encryptedPassword: user.encryptedPassword
      }).exec({
        error: function (err) {
          return res.negotiate(err);
        },
        /*
         If the password from the form params doesn't checkout w/ the encrypted
         password from the database...
         */
        incorrect: function () {
          return res.notFound();
        },
        success: function () {

          // Store user id in the user session
          console.log("User form the login check" +user)

          req.session.me = user.helpsterId;
          console.log(req.session.me);

          // All done- let the client know that everything worked.
          return res.ok();
        }
      });
    });

  }

};

Output when lifted server is [object, Object]in console

1 Answers1

4

Try it,

console.log(user);
console.log(JSON.stringify(user));
console.log("User form the login check" +user);

and write the result for us.