- Replace Street model with CouchDB-based implementation - Replace Task model with CouchDB-based implementation - Update routes to use new model interfaces - Handle geospatial queries with CouchDB design documents - Maintain adoption functionality and middleware - Use denormalized document structure with embedded data - Update test files to work with new models - Ensure API compatibility while using CouchDB underneath 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
23 lines
601 B
JavaScript
23 lines
601 B
JavaScript
const jwt = require("jsonwebtoken");
|
|
const User = require("../models/User");
|
|
|
|
module.exports = function (req, res, next) {
|
|
// Get token from header
|
|
const token = req.header("x-auth-token");
|
|
|
|
// Check if not token
|
|
if (!token) {
|
|
return res.status(401).json({ msg: "No token, authorization denied" });
|
|
}
|
|
|
|
// Verify token
|
|
try {
|
|
const decoded = jwt.verify(token, process.env.JWT_SECRET);
|
|
req.user = decoded.user;
|
|
next();
|
|
} catch (err) {
|
|
// Pass error to error handler middleware instead of throwing
|
|
return res.status(401).json({ msg: "Token is not valid" });
|
|
}
|
|
};
|