title: JWT - Retrieving Token
body: <p>I am trying to figure out how do I get the token id or a new token for an existing user using JWT. The goal is to take email and password, find it in the mongo DB, and then send back to the client the token, then store the token for the session.</p>
  
  <p>Currently when registering I encrypt the password and store the email, name, and password in a mongoDB.  </p>
  
  <p>Based on what I have been learning, the actual token is not stored in the mongoDB, but the token is generated from the _id, which I cant pull for some reason to just resign and get the token back but no luck. Any advice is greatly appreciated its for a personal project.</p>
  
  <pre><code>    User.create({
    name : req.body.name,
    email : req.body.email,
    password : req.body.password,
  },
  function (err, user) {
    if (err) return res.status(500).send("There was a problem registering the user.")
    // create a token
    var token = jwt.sign({ id: user._id }, config.secret);
    res.status(200).send({ auth: true, token: token });
  });    
  </code></pre>