mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-12-02 11:54:04 +01:00
feat(auth): sign-in-with-wallet — adopt an existing wallet-linked account instead of erroring
A Smirk wallet that already owns another account no longer fails with 'already linked to another account'. Ownership is cryptographically proven, so it's a login: the server re-points that account to the current socket and returns its session token; the client persists it and reloads to re-establish as that account. Fixes a returning user being unable to sign in from a fresh browser session. NOTE: touches the identity/session path — verify live (sign in with a wallet already linked to another account -> lands on that account with its address/credits).
This commit is contained in:
@@ -97,6 +97,16 @@ const SmirkAuth = {
|
||||
provenPublicKey = result.pubkey;
|
||||
}
|
||||
|
||||
// Sign-in-with-wallet adoption: if this wallet already owned an account, the server signed
|
||||
// us into it and returned that account's session token. Persist it and reload so the whole
|
||||
// session re-establishes as that account (credits, address, history).
|
||||
if (verifyData && verifyData.adopted && verifyData.sessionToken) {
|
||||
try { localStorage.setItem('wownerogue_token', verifyData.sessionToken); } catch (_) { /* ignore */ }
|
||||
$('#messages').append($('<li class="status">').text('🔑 Signed in to your wallet-linked account. Reloading…'));
|
||||
setTimeout(function () { window.location.reload(); }, 700);
|
||||
return { success: true, linked: true, adopted: true, address: verifyData.address || null };
|
||||
}
|
||||
|
||||
// Step 3: Get wallet addresses and auto-set payout address
|
||||
// Note: the proven public key is a pubkey (hex), NOT an address.
|
||||
// We need to call getAddresses() to get the actual WOW address.
|
||||
|
||||
Reference in New Issue
Block a user