made changes in reset token

master
varun 3 years ago
parent ca641ecdc5
commit 660084974d

@ -155,7 +155,7 @@ exports.updateTanklevels = async (req, reply) => {
// const randomNumber = Math.floor(Math.random() * capacity) // const randomNumber = Math.floor(Math.random() * capacity)
//const randomNumber = Math.floor(Math.random() * (5500 - 1000) + 1000);E //const randomNumber = Math.floor(Math.random() * (5500 - 1000) + 1000);E
// console.log(randomNumber) // console.log(randomNumber)
//console.log(Number) //console.log(tankname)
const randomNumber = Math.floor(Number/1.5) const randomNumber = Math.floor(Number/1.5)
const data = await Tank.findOneAndUpdate({ customerId: customerId, tankName: tankname }, { $set: { waterlevel: randomNumber } }); const data = await Tank.findOneAndUpdate({ customerId: customerId, tankName: tankname }, { $set: { waterlevel: randomNumber } });
Number = randomNumber Number = randomNumber

@ -203,7 +203,7 @@ fastify.post("/api/login", {
//expiresIn: expressed in seconds or a string describing a time span zeit/ms. Eg: 60, "2 days", "10h", "7d". //expiresIn: expressed in seconds or a string describing a time span zeit/ms. Eg: 60, "2 days", "10h", "7d".
//A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), //A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc),
//otherwise milliseconds unit is used by default ("120" is equal to "120ms"). //otherwise milliseconds unit is used by default ("120" is equal to "120ms").
{ expiresIn: "12h" } { expiresIn: "15d" }
); );
var arr = loginObject.user.profile.role; var arr = loginObject.user.profile.role;
var arrayToString = JSON.stringify(Object.assign({}, arr)); // convert array to string var arrayToString = JSON.stringify(Object.assign({}, arr)); // convert array to string
@ -250,19 +250,36 @@ fastify.post("/api/login", {
}, },
}); });
fastify.get("/api/reset_token/:username", { fastify.get("/api/reset_token/:customerId", {
schema: {
description: "This is for Reset Token",
tags: ["Login"],
summary: "This is for Reset Token",
params: {
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
},
async handler(req, reply) { async handler(req, reply) {
try { try {
const customerId = req.params.customerId
const get_user = await userController.getSingleUser(req); const get_user = await userController.getSingleUser(req);
const token = fastify.jwt.sign( const token = fastify.jwt.sign(
{ {
username: get_user.username, customerId: get_user.customerId,
userId: get_user._id, userId: get_user._id,
roles: get_user.profile.role, roles: get_user.profile.role,
}, },
{ expiresIn: "12h" } { expiresIn: "12h" }
); );
reply.send({ access_token: token, username: get_user.username }); reply.send({ access_token: token, customerId: get_user.customerId });
} catch (err) { } catch (err) {
console.log(err); console.log(err);
error = { error = {

Loading…
Cancel
Save