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

Support login-by-email in maybe_show_reset_password_notice(). #532

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

dd32
Copy link
Member

@dd32 dd32 commented Feb 27, 2023

The new reset-password code added in #482 / #477 fails to take into consideration that the user may have logged in with an email.

This PR does two things:

  • Defensive checks, which is especially relevant if a non-username/email login handler is in play
  • Fetches a user by email if required

The code here was copied from here with the addition of replacing strpos with str_contains for readability.

The code currently triggers a PHP notice such as this during login with a bad password, if email is used:

E_NOTICE: Trying to get property 'ID' of non-object in wp-content/plugins/two-factor/class-two-factor-core.php:665

@dd32 dd32 requested a review from iandunn February 27, 2023 06:53
@dd32 dd32 added Bug PHP Pull requests that update Php code labels Feb 27, 2023
@dd32 dd32 added this to the 0.8.0 milestone Feb 27, 2023
Copy link
Member

@iandunn iandunn left a comment

Choose a reason for hiding this comment

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

Good catch! This LGTM 👍🏻

@dd32 dd32 merged commit 5ef4cca into master Feb 28, 2023
@jeffpaul jeffpaul deleted the fix/482-login-by-email branch March 2, 2023 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug PHP Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants