diff --git a/app/controllers/jwt_controller.js b/app/controllers/jwt_controller.js index 97891fa..be3197a 100644 --- a/app/controllers/jwt_controller.js +++ b/app/controllers/jwt_controller.js @@ -24,16 +24,16 @@ module.exports.addMacValue= async(req, res, next)=>{ if (mac && mac.licency_key == key) { //Check isActive and App Version are Same - if (mac.isActive == false && mac.app_version.charAt(0) == app_version.charAt(0)) { + if (mac.isActive == false && mac.app_version.charAt(0) == app_version.charAt(0) ) { today = moment().format('YYYY/MM/DD'); - if(mac.expiry_type == 'Trail'){ + if(mac.expiry_type == 'TRAIL'){ after10days = moment().add(10, 'day'); formatedDate = after10days.format('YYYY/MM/DD'); - }else if(mac.expiry_type == 'One Year'){ + }else if(mac.expiry_type == 'ONEYR'){ after1year = moment().add(1, 'year'); formatedDate = after1year.format('YYYY/MM/DD'); - }else if(mac.expiry_type == 'Perpetual'){ + }else if(mac.expiry_type == 'LYFT'){ after20year = moment().add(20, 'year'); formatedDate = after20year.format('YYYY/MM/DD'); } @@ -56,24 +56,35 @@ module.exports.addMacValue= async(req, res, next)=>{ } else { - if (mac.isActive == true && mac.app_version.charAt(0) == app_version.charAt(0) && mac_id == mac.mac_id && mac.expiry_type != 'Trail' ) + if (mac.isActive == true && mac.app_version.charAt(0) == app_version.charAt(0) && mac_id == mac.mac_id && mac.expiry_type != 'TRAIL' ) { today = moment().format('YYYY/MM/DD'); formatedDate = mac.expiry_date; - const info={ - mac_id: mac_id, - company_name: company_name, - activation_date: today, - expiry_date : formatedDate, - isActive : true, + if(formatedDate < today){ + + const info={ + mac_id: mac_id, + company_name: company_name, + activation_date: today, + expiry_date : formatedDate, + isActive : true, + } + const macUpdate = await MacModel.update(info, {where:{id: mac.id}}); + + if (macUpdate) { + logMsg.info({status:200,message:"Your license has been successfully activated.", data: { expiry_date : cryptr.encrypt(formatedDate), expiry_type : cryptr.encrypt(mac.expiry_type) }}); + res.send({status:200,message:" Your license has been successfully activated.", data: { expiry_date : cryptr.encrypt(formatedDate), expiry_type : cryptr.encrypt(mac.expiry_type) }}) + } + + }else{ + + logMsg.info({status:404,message:"Please check the license key and try again. For further assistance, contact our support team.", data: "No Data"}); + res.send({status:404,message:"Please check the license key and try again. For further assistance, contact our support team.", data: "No Data"}) + } - const macUpdate = await MacModel.update(info, {where:{id: mac.id}}); + - if (macUpdate) { - logMsg.info({status:200,message:"Your license has been successfully activated.", data: { expiry_date : cryptr.encrypt(formatedDate), expiry_type : cryptr.encrypt(mac.expiry_type) }}); - res.send({status:200,message:" Your license has been successfully activated.", data: { expiry_date : cryptr.encrypt(formatedDate), expiry_type : cryptr.encrypt(mac.expiry_type) }}) - } }else{