This commit is contained in:
pawan-dot 2022-11-01 16:08:06 +05:30
parent 53c55e2722
commit 52a4570e85
3 changed files with 11 additions and 4 deletions

View File

@ -241,4 +241,7 @@ export const getSingleRegisterUser = async (req, res) => {
msg: "Failled to fetch !!"
});
}
}
}
//share app (api)

View File

@ -17,9 +17,13 @@ export const isAuthenticatedUser = async (req, res, next) => {
//remove Bearer from token
const fronttoken = getToken.authorization.slice(7);
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);
req.user = fuser;

View File

@ -66,7 +66,7 @@ userSchema.pre("save", async function (next) {
userSchema.methods.getJWTToken = function () {
return jwt.sign({ id: this._id }, process.env.JWT_SECRET);
};
// console.log(process.env.JWT_SECRET)
// Compare Password