My line: show payouts from an email-only session and across all owned positions
refreshMemberId falls back to the account's on-chain id when the session has no wallet address (phone sign-in by email code), without caching it into the session. /api/my/line now sums TierPaid events to every position the account owns (main id + linked positions), so each direct's 'paid you so far' is right from any device. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -146,7 +146,15 @@ async function fromRequest(req) {
|
||||
return impl().get(decodeURIComponent(m[1]));
|
||||
}
|
||||
async function refreshMemberId(sess) {
|
||||
if (!sess || !sess.address) return (sess && sess.memberId) || 0;
|
||||
if (!sess) return 0;
|
||||
if (!sess.address) {
|
||||
if (sess.memberId) return sess.memberId;
|
||||
// email-only session (phone sign-in with no wallet connected): read the account's
|
||||
// on-chain id instead, so read-only views (My line, earnings, P&L) work from any
|
||||
// device. Not cached into the session: a session without an address stays wallet-less.
|
||||
if (sess.email) { try { const a = await require('./accounts').byEmail(sess.email); if (a && a.memberId) return a.memberId; } catch (e) {} }
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
const id = await chain.memberIdByAccount(sess.address);
|
||||
if (id && id !== sess.memberId) await updateSession(sess.token, { memberId: id });
|
||||
|
||||
Reference in New Issue
Block a user