openvibers/openvibe.reviews Commits

GET /auth/me signed out answers 200 { user: null } like Blog, Community and Wiki (a 401 showed in every signed-out visitor's console) (#73)

OP OpenVibers committed 27 days ago · 17cca328e1 · 1 file, +1 −1

Changes

ddiff --git a/server/auth/session.js b/server/auth/session.js
iindex f752b85..b4d84fe 100644
---- a/server/auth/session.js
++++ b/server/auth/session.js
@@@ -180,7 +180,7 @@ function createSessionRoutes({ config, viewers, fetchImpl = globalThis.fetch, lo
router.get('/me', async (req, res) => {
const actor = await viewers.resolve(req, { services: false }).catch(() => null);
-- if (!actor || actor.kind !== 'user') return res.status(401).json({ error: 'Not authenticated' });
++ if (!actor || actor.kind !== 'user') return res.json({ user: null }); // signed out: 200 with no user (as Blog, Community, Wiki), not a 401 in every signed-out visitor's console
res.set('Cache-Control', cache.htmlHeaders({ private: true })).json({ user: actor.user });
});