cms
This commit is contained in:
parent
53c55e2722
commit
52a4570e85
@ -241,4 +241,7 @@ export const getSingleRegisterUser = async (req, res) => {
|
|||||||
msg: "Failled to fetch !!"
|
msg: "Failled to fetch !!"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//share app (api)
|
@ -17,9 +17,13 @@ export const isAuthenticatedUser = async (req, res, next) => {
|
|||||||
//remove Bearer from token
|
//remove Bearer from token
|
||||||
const fronttoken = getToken.authorization.slice(7);
|
const fronttoken = getToken.authorization.slice(7);
|
||||||
|
|
||||||
|
|
||||||
const frontdecoded = jwt.verify(fronttoken, process.env.JWT_SECRET);
|
const frontdecoded = jwt.verify(fronttoken, process.env.JWT_SECRET);
|
||||||
|
if (!frontdecoded) {
|
||||||
|
return res.status(200).json({
|
||||||
|
success: false,
|
||||||
|
message: "incorrect token",
|
||||||
|
});
|
||||||
|
}
|
||||||
const fuser = await User.findById(frontdecoded.id);
|
const fuser = await User.findById(frontdecoded.id);
|
||||||
|
|
||||||
req.user = fuser;
|
req.user = fuser;
|
||||||
|
@ -66,7 +66,7 @@ userSchema.pre("save", async function (next) {
|
|||||||
userSchema.methods.getJWTToken = function () {
|
userSchema.methods.getJWTToken = function () {
|
||||||
return jwt.sign({ id: this._id }, process.env.JWT_SECRET);
|
return jwt.sign({ id: this._id }, process.env.JWT_SECRET);
|
||||||
};
|
};
|
||||||
// console.log(process.env.JWT_SECRET)
|
|
||||||
|
|
||||||
// Compare Password
|
// Compare Password
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user