GWM : res message changes

This commit is contained in:
bitbucket 2024-05-30 17:11:55 +05:30
parent 1a445ca96b
commit 97f7a88b0b
2 changed files with 56 additions and 2555 deletions

View File

@ -14,7 +14,7 @@ module.exports.addMacValue= async(req, res, next)=>{
const {key, mac_id, mail, company_name, app_version} = req.body const {key, mac_id, mail, company_name, app_version} = req.body
const mac =await MacModel.findOne({where:{licency_key: key},raw:true}); const mac = await MacModel.findOne({where:{licency_key: key},raw:true});
//Check License Key IN DB //Check License Key IN DB
if (mac && mac.licency_key == key) if (mac && mac.licency_key == key)
{ {
@ -23,41 +23,74 @@ module.exports.addMacValue= async(req, res, next)=>{
const info={ const info={
licency_key:key, licency_key:key,
mac_id: JSON.stringify(mac_id), mac_id: mac_id,
mail: mail, mail: mail,
company_name: company_name, company_name: company_name,
isActive:true, isActive:true,
activation_date:today, activation_date:today,
expiry_date:nextFiscalYearEndDate, expiry_date:nextFiscalYearEndDate,
app_version : app_version
} }
const macUpdate = await MacModel.update(info, {where:{id: mac.id}}); const macUpdate = await MacModel.update(info, {where:{id: mac.id}});
console.log("Update "); console.log("Update ");
console.log(macUpdate); console.log(macUpdate);
if (macUpdate) { if (macUpdate) {
logMsg.info({status:200,message:"Update Success!", data: info}); logMsg.info({status:200,message:"Your license has been successfully activated. ", data: info});
res.send({status:200,message:" Update Success!", data: info}) res.send({status:200,message:"Your license has been successfully activated. ", data: info})
} }
} else {
var expiryDate = new Date(mac.expiry_date);
//Check expired or not! } else {
if (expiryDate > new Date()) {
if (mac.isActive == true && mac.app_version == app_version && mac_id == mac.mac_id)
{
const info={ const info={
licency_key: key, licency_key:key,
mac_id: mac_id,
mail: mail, mail: mail,
company_name: company_name, company_name: company_name,
isActive:true,
activation_date:today, activation_date:today,
expiry_date:nextFiscalYearEndDate, expiry_date:nextFiscalYearEndDate,
} }
logMsg.info({status:404,message:" Your Mac is Already Activated!", data: info}); const macUpdate = await MacModel.update(info, {where:{id: mac.id}});
res.send({status:404,message:" Your Mac is Already Activated!", data: info}); console.log("Update ");
console.log(macUpdate);
} else { if (macUpdate) {
logMsg.info({status:404,message:" Product Expired!", data: "No Data!"}); logMsg.info({status:200,message:"Your license has been successfully activated.", data: info});
res.send({status:404,message:" Product Expired!", data: "No Data!"}); res.send({status:200,message:" Your license has been successfully activated.", data: info})
}
}else{
logMsg.info({status:404,message:"The license key you provided is not valid. Please check the license key and try again. For further assistance, contact our support team.", data: "No Data"});
res.send({status:404,message:"The license key you provided is not valid. Please check the license key and try again. For further assistance, contact our support team.", data: "No Data"})
} }
// var expiryDate = new Date(mac.expiry_date);
// //Check expired or not!
// if (expiryDate > new Date()) {
// const info={
// licency_key: key,
// mail: mail,
// company_name: company_name,
// activation_date:today,
// expiry_date:nextFiscalYearEndDate,
// }
// logMsg.info({status:404,message:" Your Mac is Already Activated!", data: info});
// res.send({status:404,message:" Your Mac is Already Activated!", data: info});
// } else {
// logMsg.info({status:404,message:" Product Expired!", data: "No Data!"});
// res.send({status:404,message:" Product Expired!", data: "No Data!"});
// }
// const macId = JSON.parse(mac.mac_id); // const macId = JSON.parse(mac.mac_id);
// var DBData= []; // var DBData= [];
@ -97,8 +130,8 @@ module.exports.addMacValue= async(req, res, next)=>{
// } // }
} }
}else{ }else{
logMsg.info({status:404,message:" Licency Key is No Match DB!", data: "No Data"}); logMsg.info({status:404,message:"The license key you provided is not valid. Please check the license key and try again. For further assistance, contact our support team.", data: "No Data"});
res.send({status:404,message:" Licency Key is No Match DB!", data: "No Data"}) res.send({status:404,message:"The license key you provided is not valid. Please check the license key and try again. For further assistance, contact our support team.", data: "No Data"})
} }
} catch (error) { } catch (error) {
logMsg.info("addMacValue ->Internal Server Error!", error); logMsg.info("addMacValue ->Internal Server Error!", error);

2542
package-lock.json generated

File diff suppressed because it is too large Load Diff