MACIDCHECKREMOVE : AADHAVAN
This commit is contained in:
parent
e77f06fdb7
commit
a0879a8e32
@ -13,6 +13,7 @@ module.exports.addMacValue= async(req, res, next)=>{
|
|||||||
const nextFiscalYearEndDate = one_year.format('YYYY/MM/DD');
|
const nextFiscalYearEndDate = one_year.format('YYYY/MM/DD');
|
||||||
|
|
||||||
const mac =await MacModel.findOne({where:{licency_key:req.body.key}});
|
const mac =await MacModel.findOne({where:{licency_key:req.body.key}});
|
||||||
|
console.log(mac);
|
||||||
if (mac.dataValues.licency_key == req.body.key) {
|
if (mac.dataValues.licency_key == req.body.key) {
|
||||||
if (mac.dataValues.isActive == false) {
|
if (mac.dataValues.isActive == false) {
|
||||||
|
|
||||||
@ -31,29 +32,7 @@ module.exports.addMacValue= async(req, res, next)=>{
|
|||||||
res.send({status:200,message:" Update Success!", data: info})
|
res.send({status:200,message:" Update Success!", data: info})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const macId = JSON.parse(mac.mac_id);
|
|
||||||
var DBData= [];
|
|
||||||
macId.forEach(function(macid) {
|
|
||||||
DBData.push(macid.mac)
|
|
||||||
});
|
|
||||||
var BodyData = [];
|
|
||||||
var BodyValue = req.body.mac_id;
|
|
||||||
BodyValue.forEach(function(body) {
|
|
||||||
BodyData.push(body.mac)
|
|
||||||
});
|
|
||||||
|
|
||||||
function hasCommonElement(arr1, arr2) {
|
|
||||||
for (let element of arr1) {
|
|
||||||
if (arr2.includes(element)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isMatch = hasCommonElement(DBData, BodyData);
|
|
||||||
|
|
||||||
if (isMatch) {
|
|
||||||
const info={
|
const info={
|
||||||
licency_key:req.body.key,
|
licency_key:req.body.key,
|
||||||
mail: req.body.mail,
|
mail: req.body.mail,
|
||||||
@ -63,10 +42,43 @@ module.exports.addMacValue= async(req, res, next)=>{
|
|||||||
}
|
}
|
||||||
logMsg.info({status:200,message:" Your Mac is Already Activated!", data: info});
|
logMsg.info({status:200,message:" Your Mac is Already Activated!", data: info});
|
||||||
res.send({status:200,message:" Your Mac is Already Activated!", data: info});
|
res.send({status:200,message:" Your Mac is Already Activated!", data: info});
|
||||||
} else {
|
|
||||||
logMsg.info({status:404,message:" Your Mac is Not Match!", data: "No Data!"});
|
// const macId = JSON.parse(mac.mac_id);
|
||||||
res.send({status:404,message:" Your Mac is Not Match!", data: "No Data!"});
|
// var DBData= [];
|
||||||
}
|
// macId.forEach(function(macid) {
|
||||||
|
// DBData.push(macid.mac)
|
||||||
|
// });
|
||||||
|
// var BodyData = [];
|
||||||
|
// var BodyValue = req.body.mac_id;
|
||||||
|
// BodyValue.forEach(function(body) {
|
||||||
|
// BodyData.push(body.mac)
|
||||||
|
// });
|
||||||
|
|
||||||
|
// function hasCommonElement(arr1, arr2) {
|
||||||
|
// for (let element of arr1) {
|
||||||
|
// if (arr2.includes(element)) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const isMatch = hasCommonElement(DBData, BodyData);
|
||||||
|
|
||||||
|
// if (isMatch) {
|
||||||
|
// const info={
|
||||||
|
// licency_key:req.body.key,
|
||||||
|
// mail: req.body.mail,
|
||||||
|
// company_name:req.body.company_name,
|
||||||
|
// activation_date:today,
|
||||||
|
// expiry_date:nextFiscalYearEndDate,
|
||||||
|
// }
|
||||||
|
// logMsg.info({status:200,message:" Your Mac is Already Activated!", data: info});
|
||||||
|
// res.send({status:200,message:" Your Mac is Already Activated!", data: info});
|
||||||
|
// } else {
|
||||||
|
// logMsg.info({status:404,message:" Your Mac is Not Match!", data: "No Data!"});
|
||||||
|
// res.send({status:404,message:" Your Mac is Not Match!", data: "No Data!"});
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
logMsg.info({status:404,message:" Licency Key is No Match DB!", data: "No Data"});
|
logMsg.info({status:404,message:" Licency Key is No Match DB!", data: "No Data"});
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
MacModel.init(
|
MacModel.init(
|
||||||
{
|
{
|
||||||
licency_key: {type: DataTypes.STRING},
|
licency_key: {type: DataTypes.STRING},
|
||||||
mac_id:{type: DataTypes.STRING},
|
mac_id:{type: DataTypes.TEXT },
|
||||||
mail: {type: DataTypes.STRING},
|
mail: {type: DataTypes.STRING},
|
||||||
company_name: {type: DataTypes.STRING},
|
company_name: {type: DataTypes.STRING},
|
||||||
activation_date: {type: DataTypes.STRING,},
|
activation_date: {type: DataTypes.STRING,},
|
||||||
|
|||||||
@ -4,50 +4,11 @@ const bodyParser = require('body-parser');
|
|||||||
const app = express();
|
const app = express();
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
const Mycontroller = require('../controllers/jwt_controller');
|
const Mycontroller = require('../controllers/jwt_controller');
|
||||||
const { jwtTokenCheck, jwtTokenCheckDataFromDB} = require('../services/authendicate')
|
|
||||||
// const mailFormatCheck = require('../services/mailFormat.Helpper')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /generateToken:
|
|
||||||
* get:
|
|
||||||
* summary: Generate the JWT Token
|
|
||||||
* description: Create a new user with the specified details.
|
|
||||||
* responses:
|
|
||||||
* '201':
|
|
||||||
* description: User created successfully
|
|
||||||
* '400':
|
|
||||||
* description: Bad request. Invalid input or validation error.
|
|
||||||
*/
|
|
||||||
router.get('/generateToken', Mycontroller.generateToken);
|
|
||||||
|
|
||||||
router.get('/tokenChange', jwtTokenCheckDataFromDB , Mycontroller.tokenChange)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /list:
|
|
||||||
* get:
|
|
||||||
* summary: Retrieving a List of Data
|
|
||||||
* description: Retrieving a List of Data in DB
|
|
||||||
* parameters:
|
|
||||||
* - name: auth
|
|
||||||
* in: header
|
|
||||||
* description: an authorization header
|
|
||||||
* required: true
|
|
||||||
* type: string
|
|
||||||
* responses:
|
|
||||||
* '201':
|
|
||||||
* description: User created successfully
|
|
||||||
* '400':
|
|
||||||
* description: Bad request. Invalid input or validation error.
|
|
||||||
*/
|
|
||||||
router.get('/list',jwtTokenCheck, Mycontroller.list);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user