fix(together): メンバー認証済みユーザーに invite_code を返すよう修正

This commit is contained in:
posimai 2026-04-22 09:46:24 +09:00
parent 4390748534
commit b20393b8a9
1 changed files with 1 additions and 4 deletions

View File

@ -2769,7 +2769,6 @@ ${excerpt}
}); });
// GET /together/groups/:groupId — グループ情報(メンバーのみ) // GET /together/groups/:groupId — グループ情報(メンバーのみ)
// invite_code は JWT 認証済みの場合のみ返す(レガシー ?u= のみでは返さない)
r.get('/together/groups/:groupId', async (req, res) => { r.get('/together/groups/:groupId', async (req, res) => {
if (!/^[a-zA-Z0-9_-]+$/.test(req.params.groupId)) return res.status(400).json({ error: 'invalid groupId' }); if (!/^[a-zA-Z0-9_-]+$/.test(req.params.groupId)) return res.status(400).json({ error: 'invalid groupId' });
const username = normalizeTogetherUsername(req.query.u); const username = normalizeTogetherUsername(req.query.u);
@ -2778,9 +2777,7 @@ ${excerpt}
if (!(await togetherEnsureMember(pool, res, req.params.groupId, username, jwtUserId))) return; if (!(await togetherEnsureMember(pool, res, req.params.groupId, username, jwtUserId))) return;
const result = await pool.query('SELECT id, name, invite_code, created_at FROM together_groups WHERE id=$1', [req.params.groupId]); const result = await pool.query('SELECT id, name, invite_code, created_at FROM together_groups WHERE id=$1', [req.params.groupId]);
if (result.rows.length === 0) return res.status(404).json({ error: 'グループが見つかりません' }); if (result.rows.length === 0) return res.status(404).json({ error: 'グループが見つかりません' });
const group = result.rows[0]; res.json(result.rows[0]);
if (!jwtUserId) delete group.invite_code;
res.json(group);
} catch (e) { } catch (e) {
res.status(500).json({ error: 'Internal server error' }); res.status(500).json({ error: 'Internal server error' });
} }