Code box survives a board reload: the board hands back the member's started mission, a second Start reuses the live token, and submit accepts the code of any live token of theirs for that mission (ticket IAP-1027, phones that open the site in the board's own window)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-24 08:51:00 -06:00
parent d915884409
commit 21b2f5e91b
5 changed files with 481 additions and 466 deletions
+2
View File
@@ -47,6 +47,8 @@ const sleep = ms => new Promise(r => setTimeout(r, ms));
const st = await call('/api/my/start', { method: 'POST', body: JSON.stringify({ missionId: 'test-1' }) });
eq([st.status, /#ph=[a-f0-9]{32}$/.test(st.body.url)], [200, true], 'start issues a token on the mission link');
const t = st.body.token;
{ const b2 = await call('/api/my/board'); eq([b2.body.open && b2.body.open.token, b2.body.open && b2.body.open.missionId], [t, 'test-1'], 'board hands back the started mission, so the code box survives a reload');
const st2 = await call('/api/my/start', { method: 'POST', body: JSON.stringify({ missionId: 'test-1' }) }); eq([st2.status, st2.body.token === t, st2.body.started <= Date.now()], [200, true, true], 'a second Start reuses the live token (the code on screen keeps matching)'); }
// the embed's locks
const wrongOrigin = await fetch(B + '/api/embed/code?t=' + t, { headers: { Origin: 'https://evil.example' } });