Q: How to verify user using Angular JS and JWT? I am currently working on registration module. I am able to register using a form. I am using Angular JS for frontend and Nodejs for backend services. I call the API and thus it gets registered. After registering, the user gets a verification mail upon which clicking the button, the user should be successfully verified.
I have achieved till sending a mail but after clicking on 'verify button' in mail it lands onto login page directly without verifying. I want to verify the user and send the token to the verify API. I am not sure about how to go about it.

A: Use node jwt module which solve your problem.
When user login then create token for user 
var token = jwt.sign(user, app.get('superSecret'), {
              expiresIn: '1440m' // expires in 24 hours
   });
Then sent token with response each time when user try to access any url create middle-ware that will verify user token it is valid or not.
    /* Middle-ware to verify toke */
    apiRoutes.use(function(req, res, next) {
    // check header or url parameters or post parameters for token
    var token = req.body.token || req.query.token || req.headers['x- access-token'];
  // decode token
  if (token) {
    // verifies secret and checks exp
    jwt.verify(token, app.get('superSecret'), function(err, decoded) {      
      if (err) {
        return res.json({ status: 102, message: 'Failed to authenticate token.' });    
      } else {
        // if everything is good, save to request for use in other routes
        req.decoded = decoded;    
        next();
      }
    });
  } else {
    // if there is no token
    // return an error
    return res.status(403).send({ 
        success: false, 
        message: 'No token provided.' 
    });

  }
});

