no more 401 error for publicly browsing user
This commit is contained in:
@@ -416,4 +416,19 @@ router.post("/logout", (req, res) => {
|
||||
res.json({ message: "Logged out successfully" });
|
||||
});
|
||||
|
||||
// Auth status check endpoint - returns 200 regardless of auth state
|
||||
const { optionalAuth } = require("../middleware/auth");
|
||||
router.get("/status", optionalAuth, async (req, res) => {
|
||||
if (req.user) {
|
||||
res.json({
|
||||
authenticated: true,
|
||||
user: req.user
|
||||
});
|
||||
} else {
|
||||
res.json({
|
||||
authenticated: false
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user