Skip to content

lantern-core: centralize ApplyUserDataToSettings + extend to purchase paths#8805

Open
myleshorton wants to merge 1 commit into
fisk/login-patch-settingsfrom
fisk/identity-helper-purchase-paths
Open

lantern-core: centralize ApplyUserDataToSettings + extend to purchase paths#8805
myleshorton wants to merge 1 commit into
fisk/login-patch-settingsfrom
fisk/identity-helper-purchase-paths

Conversation

@myleshorton
Copy link
Copy Markdown
Contributor

Stacked on top of #8804.

What

  1. Move the applyUserDataToSettings helper (added per-platform in lantern-core: propagate identity to settings on Login/Logout/OAuth/DeleteAccount (mobile + FFI) #8804) into a single exported lanterncore.ApplyUserDataToSettings in lantern-core/core.go, and drop the duplicate copies from lantern-core/mobile/mobile.go and lantern-core/ffi/ffi.go.
  2. Wire the helper into the purchase / restore flows that also switch the active account on the server side:
    • AcknowledgeGooglePurchase
    • AcknowledgeApplePurchase
    • restoreSubscription (only when the server returns a different ActualUserID)

Why

#8804 fixed the Pro-server-list-collapse bug for Login / OAuthLoginCallback / Logout / DeleteAccount, but a small residual hole remained: when a purchase or a restoreSubscription causes radiance to switch accounts, only the in-process setData runs. On the macOS two-process build, that doesn't reach the canonical settings.json the network-extension config fetcher reads from, so /v1/config-new requests can briefly continue to advertise the pre-switch identity. Routing the post-switch identity update through PatchSettings (same path the rest of the purchase code already uses for tier/expiration) closes the gap and matches the post-Login behavior introduced in #8804.

The centralization makes it harder to drift mobile and ffi out of sync as more identity-changing entry points get added.

Verification

  • go vet ./lantern-core/... — clean
  • go build ./lantern-core/... — clean
  • go test ./lantern-core/... — passes

Identity-changing entry points covered after this PR:

Entry point Path Covered by
Login mobile + ffi #8804
OAuthLoginCallback mobile + ffi #8804
Logout mobile + ffi #8804
DeleteAccount mobile + ffi #8804
AcknowledgeGooglePurchase mobile this PR
AcknowledgeApplePurchase mobile this PR
restoreSubscription (cross-account) mobile this PR

🤖 Generated with Claude Code

…paths

Consolidates the per-platform applyUserDataToSettings helper introduced
on this branch into a single exported function in lantern-core/core.go,
removing the duplicate copies from lantern-core/mobile/mobile.go and
lantern-core/ffi/ffi.go.

Also wires it into the purchase / restore flows
(AcknowledgeGooglePurchase, AcknowledgeApplePurchase, restoreSubscription)
so account-switching purchases propagate the full identity (user_level,
email, jwt_token) through PatchSettings rather than relying on radiance's
internal setData, which only writes the caller's in-process settings
cache and doesn't reach the canonical store the system extension reads.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 21, 2026 18:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes the post-identity-change settings propagation logic into a single lanterncore.ApplyUserDataToSettings helper, and ensures purchase/restore flows also update the canonical settings store after server-side account switching (closing a remaining macOS two-process settings drift gap).

Changes:

  • Moved duplicated applyUserDataToSettings implementations from mobile + FFI layers into lantern-core/core.go as exported ApplyUserDataToSettings.
  • Updated mobile + FFI identity-changing entry points (Login/OAuth callback/Logout/DeleteAccount) to call the centralized helper.
  • Extended the same “patch canonical settings” behavior to cross-account purchase acknowledgements and restore-subscription account switches on mobile.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
lantern-core/mobile/mobile.go Removes local helper, uses centralized helper, and applies it after cross-account purchase/restore flows.
lantern-core/ffi/ffi.go Removes local helper and switches identity-changing calls to use the centralized helper.
lantern-core/core.go Introduces exported ApplyUserDataToSettings to patch canonical settings from account.UserData.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants