no more 401 error for publicly browsing user

This commit is contained in:
jackiettran
2025-10-07 11:43:05 -04:00
parent 9a9e96d007
commit 299522b3a6
8 changed files with 1272 additions and 249 deletions

View File

@@ -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;