Game sign-in kit: a remembered sign-in on this device opens on 'Continue as @name' (new POST /api/game/auth/resume turns the 29-day kit pass into a fresh hand-off token, no code; pass checked for this game, suspended accounts refused), 'Use a different account' falls back to email; Shards of Valor login ad uses the card view (frames: false)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-19 17:26:15 -05:00
parent 7af47ae921
commit 0e528ae854
2 changed files with 33 additions and 3 deletions
+22 -2
View File
@@ -116,7 +116,7 @@
function err(m) { var e = el.querySelector('.err'); if (e) e.textContent = m || ''; }
function busy(on) { var b = el.querySelector('.go'); if (b) { b.disabled = !!on; if (on) b.dataset.l = b.textContent, b.textContent = 'One moment…'; else if (b.dataset.l) b.textContent = b.dataset.l; } }
function done(r) {
if (r.pass) ls(PASS_KEY, JSON.stringify({ p: r.pass, exp: Date.now() + 29 * 86400000, email: email }));
if (r.pass) { var prev = getPass(); ls(PASS_KEY, JSON.stringify({ p: r.pass, exp: Date.now() + 29 * 86400000, email: email || (prev && prev.email) || '', name: r.username || (prev && prev.name) || '' })); }
if (r.needUsername) return stepName(r);
if (r.token) { // a fresh sign-in: the login ad first (fails open to the hand-off)
if (opt.loginAd === false) return onToken(r.token);
@@ -200,7 +200,27 @@
});
setTimeout(function () { try { f.u.focus(); } catch (e) {} }, 50);
}
stepEmail();
// signed in on this device before (the 29-day pass): one tap, no code (Dallas 2026-10-19: "only a name and login with
// InstantAdPay, it should take care of the rest"). Remembered sign-ins skip the login ad, as before.
function stepResume(saved) {
var who = saved.name ? '@' + saved.name : (saved.email || 'your InstantAdPay account');
el.innerHTML = '<h2>' + esc(opt.title || 'Sign in to play') + '</h2><p>You are signed in on this device as <b>' + esc(who) + '</b>.</p>'
+ '<div class="err" role="alert"></div><button class="go" type="button" data-go>Continue as ' + esc(who) + '</button>'
+ '<div class="row"><button class="lk" type="button" data-other>Use a different account</button></div>';
el.querySelector('[data-go]').addEventListener('click', function () {
err(''); busy(true);
post('/api/game/auth/resume', { game: game, pass: saved.p }).then(function (x) {
busy(false);
if (x.ok && x.pass) ls(PASS_KEY, JSON.stringify({ p: x.pass, exp: Date.now() + 29 * 86400000, email: saved.email || '', name: x.username || saved.name || '' }));
if (x.ok && x.needUsername) return stepName(x);
if (x.ok && x.token) return onToken(x.token);
ls(PASS_KEY, null); stepEmail(x.error || 'Your sign-in expired. Start again with your email.');
});
});
el.querySelector('[data-other]').addEventListener('click', function () { ls(PASS_KEY, null); stepEmail(); });
}
var saved = opt.resume === false ? null : getPass();
if (saved) stepResume(saved); else stepEmail();
}
// nudge: open InstantAdPay in a new tab already signed in (the pass posts in a form, never in a URL)