Gem Kingdom sign-in carries a feed post's ?ref through to IAP sign-up
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2510,7 +2510,9 @@ const server = http.createServer(async (req, res) => {
|
||||
// -- Gem Kingdom hand-off (2026-10-01): sign the member across; the game verifies with GK_SSO_SECRET
|
||||
if (p === '/api/my/gemkingdom' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Set-Cookie': gkCookie('iap.return', 'gemkingdom', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
// a newcomer from a Gem Kingdom feed post carries the poster's ?ref through to /my, where the viral-link rule sets the sponsor
|
||||
const gkRef = String(u.searchParams.get('ref') || '').trim().toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 20);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + (gkRef ? '?ref=' + encodeURIComponent(gkRef) : ''), 'Set-Cookie': gkCookie('iap.return', 'gemkingdom', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (GK_SECRET().length < 32) return json(res, 503, { error: 'Gem Kingdom is not connected yet.' });
|
||||
const acct = await accounts.byEmail(s.email);
|
||||
const tok = gkMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null });
|
||||
|
||||
Reference in New Issue
Block a user