I am not following any third party example.
router.post('/activation/activate', function (req, res) { let license = req.param('license'); if(license){ let success = false;
ta.CheckAndSavePKey(license, TA_USER) .then((retObj) => {
// the product key was valid and saved successfully if (retObj === TA_OK) return ta.Activate(); else // TA_FAIL { console.log("Something failed! " + retObj, 1); return null; } }) .then((retObj) => { // result from Activate()
console.log("retObj "+retObj); console.log("retObj[0] "+retObj[0]); // if null, fall through if (retObj === null) return null;
if (retObj[0] === TA_OK) { // the customer activated successfully, begin your app success = true; console.log("Activation Successful.", retObj);
} else { console.log("Activation failed.", retObj); } }) .catch((retObj) => { // an error somewhere in the processing console.log("Something failed! " + retObj, 1); });
if(success){ loadmyapp(); }else{ return res.status(401).send(' Activation failed! '); } }});
Console Outout:
retObj 0retObj[0] undefinedActivation failed. 0
If I refresh my page I can login as I am checking (ta.IsGenuineEx) if its not activated got to above function else load the app. So on refresh ta.IsGenuineEx comes true.