Skip to content

Commit

Permalink
Merge pull request #2561 from dparker1005/invalidkey-fix
Browse files Browse the repository at this point in the history
Fixing logic for invalidkey password reset error
  • Loading branch information
dparker1005 authored Aug 7, 2023
2 parents 5cb6ec6 + 42052c6 commit df1538b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions includes/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ function pmpro_do_password_reset() {
// If the key is expired or invalid, figure out the correct error code.
if ( is_wp_error( $check ) ) {
$error_code = $check->get_error_code() == 'expired_key' ? 'expiredkey' : 'invalidkey';
} elseif ( gettype( $check ) !== 'WP_User' ) {
} elseif ( ! is_a( $check, 'WP_User' ) ) {
// Probably null/false returned from a plugin filtering the check.
$error_code = 'invalidkey';
}
Expand Down Expand Up @@ -846,7 +846,8 @@ function pmpro_do_password_reset() {

// Parameter checks OK, reset password.
// Note: Can't sanitize the password.
reset_password( $user, $_POST['pass1'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
// $check must be a WP_User object at this point, otherwise $error_code would be set and we'd have already redirected.
reset_password( $check, $_POST['pass1'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
wp_redirect( add_query_arg( urlencode( 'password' ), urlencode( 'changed' ), $redirect_url ) );
} else {
esc_html_e( 'Invalid Request', 'paid-memberships-pro' );
Expand Down

0 comments on commit df1538b

Please sign in to comment.