Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Premium Content: Display subscriber view to logged in users who have subscribed #45777

Merged
merged 3 commits into from
Sep 21, 2020

Conversation

mmtr
Copy link
Member

@mmtr mmtr commented Sep 21, 2020

Changes proposed in this Pull Request

  • Fix the token subscription service of the Premium Content block so the subscriber view is rendered for logged in users who are subscribed to the plan used in the block, even if the token/auth cookie is missing.
  • The block has been completely broken since changes from Remove deprecated blockType.context support WordPress/gutenberg#24155 and Recurring Payments: Replace submit button jetpack#15915 landed in WP.com. The first dropped support for the context property when registering a block in favor of a new usesContext, while the latter dropped support for the submitButtonText attribute of the jetpack/recurring-payments block in favor of the inner jetpack/button block's text attribute. This PR updates the code so block is usable again:
Before After
Sep-21-2020 12-34-17 Sep-21-2020 15-15-44

Testing instructions

  • Modify your /etc/hosts file and point the addresses below to your WP.com sandbox IP:
    • public-api.wordpress.com.
    • subscribe.wordpress.com.
    • The address of a WP.com simple site under a paid plan.
  • Add the code below to the /wp-content/mu-plugins/0-sandbox.php file of your WP.com sandbox:
define( 'USE_STORE_SANDBOX', true );
define( 'USE_BILLING_SANDBOX', true );
define( 'BILLINGDADDY_SANDBOX', rtrim( 'https://' . `hostname` ) );
  • Checkout this branch and run cd apps/editing-toolkit && yarn dev --sync
  • Go to https://wordpress.com/block-editor.
  • Select the WP.com simple site you sandboxed above.
  • Insert a Premium Content block.
  • Make sure you can easily change the plan from the block toolbar.
  • Publish the post.
  • Visit the post in an incognito/private session.
  • Subscribe to the Premium Content plan using a secondary account which don't have access to the WP.com simple site you sandboxed above.
  • Make sure the protected content is visible.
  • Close the incognito/private session and visit wordpress.com/login in an incognito/private session (this is to make sure any auth cookie is gone).
  • Log in as the secondary account you used above.
  • Visit the post that contains the Premium Content block.
  • Make sure the protected content is visible.

Fixes #45663
Fixes #45498

@mmtr mmtr added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Premium Content Controlling specific content for paying site visitors. labels Sep 21, 2020
@mmtr mmtr requested a review from a team September 21, 2020 13:28
@mmtr mmtr self-assigned this Sep 21, 2020
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@matticbot
Copy link
Contributor

Caution: This PR affects files in the Editing Toolkit Plugin on WordPress.com
Please ensure your changes work on WordPress.com before merging.

D49931-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing the Editing Toolkit Plugin for more info: PCYsg-ly5-p2

@kwight
Copy link
Contributor

kwight commented Sep 21, 2020

Fantastic, well done @mmtr – and thanks for identifying where the regressions happened ❤️

Copy link
Contributor

@kwight kwight left a comment

Choose a reason for hiding this comment

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

Tried with multiple users in different logged-in/out states, all behaved as expected. 🎉

@blackjackkent
Copy link
Contributor

Verified on my end as well! Looks good.

@kwight kwight merged commit 477cf56 into master Sep 21, 2020
@kwight kwight deleted the fix/premium-content-login-button-visibility branch September 21, 2020 20:08
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Premium Content Controlling specific content for paying site visitors.
Projects
None yet
5 participants