Skip to content

Conversation

@xecdev
Copy link
Collaborator

@xecdev xecdev commented Dec 13, 2025

This PR fixes #110. by updating the auto-login logic so the wallet used for an unlock replaces the currently logged-in wallet, ensuring correct switching during consecutive unlocks.

Test Plan:

  • Install the plugin
  • Unlock a content with wallet A
  • Now unlock a content with wallet B
  • Make sure your wallet is updated to B (you can confirm by checking the Profile page)

Summary by CodeRabbit

  • Bug Fixes
    • Improved automatic login behavior for wallet address changes. Users can now successfully auto-login when switching to a different wallet address, while unnecessary re-processing of the same address is prevented.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 13, 2025

Walkthrough

The auto-login logic in mark_payment_successful is updated to enable wallet switching. Previously, auto-login only occurred when no wallet address was stored. The new logic allows auto-login when a different wallet address is provided, supporting users who unlock content with a new wallet.

Changes

Cohort / File(s) Summary
Auto-login wallet switching logic
includes/class-paybutton-ajax.php
Modified condition in mark_payment_successful to trigger auto-login when a non-empty wallet address differs from the stored address, enabling wallet switching instead of only supporting initial login

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file with one method's conditional logic refined
  • The change is a straightforward condition adjustment from checking for absent address to checking for different address
  • Clear relationship to issue #110 with explicit intent

Possibly related PRs

Suggested labels

enhancement (UI/UX/feature)

Suggested reviewers

  • Klakurka

Poem

🐰 A wallet swap, so swift and clean,
No more locked doors in between!
When users unlock with a different key,
Auto-login switches gracefully ✨
Now wallets dance, as users please!

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: enabling wallet switching during auto-login, which is the core objective of the PR.
Linked Issues check ✅ Passed The code change directly addresses issue #110 by modifying auto-login logic to allow wallet switching when a different address is used, replacing the old behavior that only auto-logged in when no wallet was stored.
Out of Scope Changes check ✅ Passed The change is narrowly focused on the auto-login logic in the mark_payment_successful function, directly aligned with issue #110 requirements with no extraneous modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/switch-wallet-in-auto-login

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff49711 and 8a5fb29.

📒 Files selected for processing (1)
  • includes/class-paybutton-ajax.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
includes/class-paybutton-ajax.php (1)
includes/class-paybutton-state.php (2)
  • PayButton_State (4-312)
  • get_address (170-181)
🔇 Additional comments (1)
includes/class-paybutton-ajax.php (1)

345-349: LGTM! The wallet switching logic is correctly implemented.

The change successfully enables wallet switching during consecutive unlocks. The logic now updates the stored wallet address whenever an unlock is performed with a different wallet, rather than only when no wallet is stored.

Implementation is sound:

  • The wallet address is sourced from a validated database row
  • Strict comparison (!==) ensures proper equality checking
  • The ! empty() check prevents setting empty values
  • The condition correctly enables the wallet switching use case

Recommendation: Verify that switching wallets doesn't break dependent features by checking how other parts of the codebase rely on the stored wallet address through PayButton_State::get_address() calls.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@xecdev xecdev self-assigned this Dec 13, 2025
@xecdev xecdev added the bug Something isn't working label Dec 13, 2025
@xecdev xecdev requested a review from Klakurka December 13, 2025 13:45
@Klakurka Klakurka merged commit 93351f1 into master Dec 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch wallet in auto-login when unlocking with a new address

3 participants