Changeset 59828 for trunk/src/wp-includes/user.php
- Timestamp:
- 02/17/2025 11:22:33 AM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r59817 r59828 206 206 } 207 207 208 if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) ) { 208 $valid = wp_check_password( $password, $user->user_pass, $user->ID ); 209 210 if ( ! $valid ) { 209 211 return new WP_Error( 210 212 'incorrect_password', … … 220 222 } 221 223 224 if ( wp_password_needs_rehash( $user->user_pass, $user->ID ) ) { 225 wp_set_password( $password, $user->ID ); 226 } 227 222 228 return $user; 223 229 } … … 283 289 } 284 290 285 if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) ) { 291 $valid = wp_check_password( $password, $user->user_pass, $user->ID ); 292 293 if ( ! $valid ) { 286 294 return new WP_Error( 287 295 'incorrect_password', … … 295 303 '</a>' 296 304 ); 305 } 306 307 if ( wp_password_needs_rehash( $user->user_pass, $user->ID ) ) { 308 wp_set_password( $password, $user->ID ); 297 309 } 298 310 … … 446 458 447 459 foreach ( $hashed_passwords as $key => $item ) { 448 if ( ! wp_check_password( $password, $item['password'], $user->ID) ) {460 if ( ! WP_Application_Passwords::check_password( $password, $item['password'] ) ) { 449 461 continue; 450 462 } … … 2432 2444 * @since 4.9.0 2433 2445 * @since 5.8.0 The `$userdata` parameter was added. 2446 * @since 6.8.0 The user's password is now hashed using bcrypt instead of phpass. 2434 2447 * 2435 2448 * @param array $data { … … 2979 2992 * @since 4.4.0 2980 2993 * 2981 * @global PasswordHash $wp_hasher Portable PHP password hashing framework instance.2982 *2983 2994 * @param WP_User $user User to retrieve password reset key for. 2984 2995 * @return string|WP_Error Password reset key on success. WP_Error on error. 2985 2996 */ 2986 2997 function get_password_reset_key( $user ) { 2987 global $wp_hasher;2988 2989 2998 if ( ! ( $user instanceof WP_User ) ) { 2990 2999 return new WP_Error( 'invalidcombo', __( '<strong>Error:</strong> There is no account with that username or email address.' ) ); … … 3032 3041 do_action( 'retrieve_password_key', $user->user_login, $key ); 3033 3042 3034 // Now insert the key, hashed, into the DB. 3035 if ( empty( $wp_hasher ) ) { 3036 require_once ABSPATH . WPINC . '/class-phpass.php'; 3037 $wp_hasher = new PasswordHash( 8, true ); 3038 } 3039 3040 $hashed = time() . ':' . $wp_hasher->HashPassword( $key ); 3043 $hashed = time() . ':' . wp_fast_hash( $key ); 3041 3044 3042 3045 $key_saved = wp_update_user( … … 3064 3067 * @since 3.1.0 3065 3068 * 3066 * @global PasswordHash $wp_hasher Portable PHP password hashing framework instance. 3067 * 3068 * @param string $key Hash to validate sending user's password. 3069 * @param string $key The password reset key. 3069 3070 * @param string $login The user login. 3070 3071 * @return WP_User|WP_Error WP_User object on success, WP_Error object for invalid or expired keys. … … 3075 3076 $login 3076 3077 ) { 3077 global $wp_hasher;3078 3079 3078 $key = preg_replace( '/[^a-z0-9]/i', '', $key ); 3080 3079 … … 3091 3090 if ( ! $user ) { 3092 3091 return new WP_Error( 'invalid_key', __( 'Invalid key.' ) ); 3093 }3094 3095 if ( empty( $wp_hasher ) ) {3096 require_once ABSPATH . WPINC . '/class-phpass.php';3097 $wp_hasher = new PasswordHash( 8, true );3098 3092 } 3099 3093 … … 3119 3113 } 3120 3114 3121 $hash_is_correct = $wp_hasher->CheckPassword( $key, $pass_key );3115 $hash_is_correct = wp_verify_fast_hash( $key, $pass_key ); 3122 3116 3123 3117 if ( $hash_is_correct && $expiration_time && time() < $expiration_time ) { … … 3134 3128 /** 3135 3129 * Filters the return value of check_password_reset_key() when an 3136 * old-style key is used.3130 * old-style key or an expired key is used. 3137 3131 * 3138 3132 * @since 3.7.0 Previously plain-text keys were stored in the database. … … 3155 3149 * @since 5.7.0 Added `$user_login` parameter. 3156 3150 * 3157 * @global wpdb $wpdb WordPress database abstraction object. 3158 * @global PasswordHash $wp_hasher Portable PHP password hashing framework instance. 3151 * @global wpdb $wpdb WordPress database abstraction object. 3159 3152 * 3160 3153 * @param string $user_login Optional. Username to send a password retrieval email for. … … 4937 4930 * @since 4.9.6 4938 4931 * 4939 * @global PasswordHash $wp_hasher Portable PHP password hashing framework instance.4940 *4941 4932 * @param int $request_id Request ID. 4942 4933 * @return string Confirmation key. 4943 4934 */ 4944 4935 function wp_generate_user_request_key( $request_id ) { 4945 global $wp_hasher;4946 4947 4936 // Generate something random for a confirmation key. 4948 4937 $key = wp_generate_password( 20, false ); 4949 4938 4950 // Return the key, hashed. 4951 if ( empty( $wp_hasher ) ) { 4952 require_once ABSPATH . WPINC . '/class-phpass.php'; 4953 $wp_hasher = new PasswordHash( 8, true ); 4954 } 4955 4939 // Save the key, hashed. 4956 4940 wp_update_post( 4957 4941 array( 4958 4942 'ID' => $request_id, 4959 4943 'post_status' => 'request-pending', 4960 'post_password' => $wp_hasher->HashPassword( $key ),4944 'post_password' => wp_fast_hash( $key ), 4961 4945 ) 4962 4946 ); … … 4969 4953 * 4970 4954 * @since 4.9.6 4971 *4972 * @global PasswordHash $wp_hasher Portable PHP password hashing framework instance.4973 4955 * 4974 4956 * @param string $request_id ID of the request being confirmed. … … 4981 4963 $key 4982 4964 ) { 4983 global $wp_hasher;4984 4985 4965 $request_id = absint( $request_id ); 4986 4966 $request = wp_get_user_request( $request_id ); … … 5000 4980 } 5001 4981 5002 if ( empty( $wp_hasher ) ) {5003 require_once ABSPATH . WPINC . '/class-phpass.php';5004 $wp_hasher = new PasswordHash( 8, true );5005 }5006 5007 4982 /** 5008 4983 * Filters the expiration time of confirm keys. … … 5015 4990 $expiration_time = $key_request_time + $expiration_duration; 5016 4991 5017 if ( ! $wp_hasher->CheckPassword( $key, $saved_key ) ) {4992 if ( ! wp_verify_fast_hash( $key, $saved_key ) ) { 5018 4993 return new WP_Error( 'invalid_key', __( 'The confirmation key is invalid for this personal data request.' ) ); 5019 4994 }
Note: See TracChangeset
for help on using the changeset viewer.