Game Pass tier testing moves to Admin > Game Pass (Marty 2026-10-25): the member Games card shows every account, the admin's included, exactly what a member sees (weekly pass only while sovTiers is off; a holder sees the tier they hold). The /my admin preview note and the admin bypass on GET /api/my/gamepass and POST /api/my/gamepass/buy are gone. New Admin > Game Pass > Tier test and preview card (labelled TEST / PREVIEW): all five tiers as members will see them with on-sale/hidden chips and the admin's own status, Test buy (real waiting order fulfilled by a fresh package), Cancel test order, Give my account (test comp, no sale), End. New admin-only routes GET /api/admin/gamepass/preview, POST /api/admin/gamepass/test-buy | test-cancel | test-comp, always on the signed-in admin's own account. sovTiers untouched. QA: sov-passes-local + store reworked to the new flow (all pass); my.js and admin.js ?v= bumped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4085,7 +4085,8 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
if (p === '/api/my/gamepass' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
return json(res, 200, gamepass.view(s.email, gpDevNow(u.searchParams.get('devDay')), { admin: !!ADMIN_EMAIL && String(s.email).toLowerCase() === ADMIN_EMAIL }));
|
||||
// 2026-10-25 (Marty): the member card shows every account exactly what a member sees, the admin's included; tier testing lives in Admin > Game Pass
|
||||
return json(res, 200, gamepass.view(s.email, gpDevNow(u.searchParams.get('devDay'))));
|
||||
}
|
||||
if (p === '/api/my/gamepass/buy' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
@@ -4093,10 +4094,26 @@ const server = http.createServer(async (req, res) => {
|
||||
const b = await readBody(req);
|
||||
// 2026-10-22 (Marty): no pass is ever bought with credits. Buy only opens a waiting order; a FRESH package purchase of at least the
|
||||
// tier price, by one of this member's own positions, fulfils it (gamepass.onEvent), so the sponsor and team are paid as usual.
|
||||
// tier: weekly (missing) | explorer | champion | sovereign | legend; every tier above weekly is refused unless sovTiers is on, except for the ADMIN_EMAIL account (testing)
|
||||
const r = gamepass.buy(s.email, gpDevNow(b.devDay), b.tier, { admin: !!ADMIN_EMAIL && String(s.email).toLowerCase() === ADMIN_EMAIL });
|
||||
// tier: weekly (missing) | explorer | champion | sovereign | legend; every tier above weekly is refused unless sovTiers is on, for every
|
||||
// account (2026-10-25: the admin tests hidden tiers from Admin > Game Pass, POST /api/admin/gamepass/test-buy, not from the member card)
|
||||
const r = gamepass.buy(s.email, gpDevNow(b.devDay), b.tier);
|
||||
return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
// Admin > Game Pass tier test (2026-10-25, Marty): every tier as members will see it, with the admin's OWN account's state, and a
|
||||
// test buy of a tier that is not on sale yet (opens the same waiting order a member gets; a fresh package on /my fulfils it).
|
||||
// Always the signed-in admin's own account (the bearer password falls back to ADMIN_EMAIL); never another member's.
|
||||
if (p.startsWith('/api/admin/gamepass/') && ['/api/admin/gamepass/preview', '/api/admin/gamepass/test-buy', '/api/admin/gamepass/test-cancel', '/api/admin/gamepass/test-comp'].includes(p)) {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const as = adminFromRequest(req); const me = String((as && as.email) || ADMIN_EMAIL || '').trim().toLowerCase();
|
||||
if (!me) return json(res, 400, { error: 'No admin account email (ADMIN_EMAIL) is set.' });
|
||||
if (p === '/api/admin/gamepass/preview' && req.method === 'GET') return json(res, 200, Object.assign({ email: me, test: true }, gamepass.view(me, gpDevNow(u.searchParams.get('devDay')), { preview: true })));
|
||||
if (req.method === 'POST') {
|
||||
const b = await readBody(req); const tier = String(b.tier || 'weekly').toLowerCase(); if (!gamepass.TIERS.includes(tier)) return json(res, 400, { error: 'unknown tier' });
|
||||
if (p === '/api/admin/gamepass/test-buy') { const r = gamepass.buy(me, gpDevNow(b.devDay), tier, { preview: true }); if (!r.error) console.log('gamepass admin test order', tier, me); return json(res, r.error ? 400 : 200, Object.assign({ email: me, test: true }, r)); }
|
||||
if (p === '/api/admin/gamepass/test-cancel') { const r = gamepass.cancelOrder(me, tier); if (r.order) console.log('gamepass admin test order cancelled', tier, me); return json(res, 200, Object.assign({ email: me }, r)); }
|
||||
if (p === '/api/admin/gamepass/test-comp') { const r = gamepass.comp(me, 'admin tier test', tier); console.log('gamepass admin test comp', tier, me); return json(res, 200, Object.assign({ ok: true, email: me, test: true }, r)); }
|
||||
}
|
||||
}
|
||||
if (!IS_PROD && p === '/api/dev/gamepass-purchase' && req.method === 'POST') { const b = await readBody(req); return json(res, 200, { order: await gamepass.onEvent({ type: 'Purchase', priceCents: Number(b.cents) || 500, buyerId: 0, tx: /^0x[0-9a-f]{64}$/.test(String(b.tx || '')) ? b.tx : '0x' + crypto.randomBytes(32).toString('hex'), ts: Date.now(), devEmail: b.email, devMinedAt: Number(b.minedAt) || 0, devNow: Number(b.now) || 0 }) }); } // local tests only (minedAt fakes the block time, now the fulfilment time, tx replays a hash)
|
||||
if (p === '/api/admin/gamepass/stats' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, gamepass.adminStats()); }
|
||||
if (p === '/api/admin/gamepass/comp' && req.method === 'POST') { // support: give an account a pass week without a purchase
|
||||
|
||||
Reference in New Issue
Block a user