diff --git a/public/my.html b/public/my.html index 488fc84..94fac9e 100644 --- a/public/my.html +++ b/public/my.html @@ -31,5 +31,5 @@ - + diff --git a/public/profile-gate.js b/public/profile-gate.js index 4970c91..38ad5e0 100644 --- a/public/profile-gate.js +++ b/public/profile-gate.js @@ -167,7 +167,8 @@ // who has not proved they own the position (the API 401s them). async function require_() { try { state = await api('/api/public/profile'); } - catch (e) { return null; } // not signed in: nothing to gate + catch (e) { return null; } + if (!state || state.signedIn === false) return null; // a visitor on a shared link: never gate if (state.profile && state.profile.complete) return state.profile; if (back) return null; // already open shell(); diff --git a/server.js b/server.js index ae2187e..828b947 100644 --- a/server.js +++ b/server.js @@ -1449,7 +1449,9 @@ async function handleApi(req,res,pathname){ // Telegram Mini App bridge) can read or write one; /my/ is public and can not. if(req.method==='GET'&&pathname==='/api/public/profile'){ const s=messages.authFromCookie(req); - if(!s)return json(res,401,{error:'Not signed in.'}); + // 200 with signedIn:false, not 401: a shared /my/ link is opened by people + // who are not members, and a 401 there prints a console error that reads like a broken page. + if(!s)return json(res,200,{ok:true,signedIn:false}); return json(res,200,Object.assign({ok:true,id:s.id,suggest:profiles.suggest(s.id)},profiles.status(s.id))); } if(req.method==='POST'&&pathname==='/api/public/profile/username'){