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

Add Sign in with Google button on any use of the wp_login_form function. #10308

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

benbowler
Copy link
Collaborator

@benbowler benbowler commented Mar 4, 2025

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

Copy link

github-actions bot commented Mar 4, 2025

Build files for 00dee09 are ready:

Copy link
Collaborator

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

If a login form is output even when the user is authenticated, when the user signs in with this button, it should be treated as a "new" login, the same as the wp-login.php flow.

Can you please add more explicit steps in the QA brief for this scenario? The login form should be tested with/without an authenticated user, and also with/without rendering of the form with an authenticated user. The Sign in with Google button behaviour linking an account should be checked, but also what should be QA'd is the edge-case flow of:

  • WordPress User A is signed in to WordPress
  • WordPress User B exists whose email is used to Sign in with Google ([email protected])
  • WordPress User A is signed in to WordPress, sees the form, and signs in with Google using User B's email/Google account ([email protected])
  • An error should occur because the Google Account is already linked.

@benbowler
Copy link
Collaborator Author

Hey @tofumatt, because of this line:

<?php if ( ! is_user_logged_in() || $is_wp_login ) : // phpcs:ignore Generic.WhiteSpace.ScopeIndent.Incorrect ?>

.. the button doesn't render for logged in users currently.

If I force it to render and test the case you mentioned above, an error doesn't occur, instead a fresh login happens and the user is now logged in as the user who first connected their account with Google and has the matching wp_googlesitekitpersistent_siwg_google_user_hid value.

Is this the expected behaviour?

As for QA'ing, as the button doesn't render when logged in this is a tricky case for QA to test without modifying code. I've updated the QAB, let me know if you are happy with the cases I have listed to test.

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