admin soft delete functionality, also fixed google sign in when user doesn't have first and last name
This commit is contained in:
@@ -127,4 +127,23 @@ const requireVerifiedEmail = (req, res, next) => {
|
||||
next();
|
||||
};
|
||||
|
||||
module.exports = { authenticateToken, optionalAuth, requireVerifiedEmail };
|
||||
// Require admin role middleware - must be used after authenticateToken
|
||||
const requireAdmin = (req, res, next) => {
|
||||
if (!req.user) {
|
||||
return res.status(401).json({
|
||||
error: "Authentication required",
|
||||
code: "NO_AUTH",
|
||||
});
|
||||
}
|
||||
|
||||
if (req.user.role !== "admin") {
|
||||
return res.status(403).json({
|
||||
error: "Admin access required",
|
||||
code: "INSUFFICIENT_PERMISSIONS",
|
||||
});
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
module.exports = { authenticateToken, optionalAuth, requireVerifiedEmail, requireAdmin };
|
||||
|
||||
Reference in New Issue
Block a user