Untitled
unknown
plain_text
2 years ago
728 B
9
Indexable
const router = require("express").Router();
const jwt = require("jsonwebtoken");
const config = require("../../../config.json");
router.post("/", (req, res) => {
const { token } = req.body;
if (!token) {
return res.status(400).json({
success: false,
message: "No token provided."
});
}
try {
const decoded = jwt.verify(token, config.jwt_secret);
return res.status(200).json({
success: true,
decoded
});
} catch (error) {
return res.status(401).json({
success: false,
message: "Invalid or expired token.",
error: error.message
});
}
});
module.exports = router;
Editor is loading...
Leave a Comment