WordPress/wp-includes/class-wp-user-request.php
John Blackbourn 05770e25c3 Security: Switch to using bcrypt for hashing user passwords and BLAKE2b for hashing application passwords and security keys.
Passwords and security keys that were saved in prior versions of WordPress will continue to work. Each user's password will be opportunistically rehashed and resaved when they next subsequently log in using a valid password.

The following new functions have been introduced:

* `wp_password_needs_rehash()`
* `wp_fast_hash()`
* `wp_verify_fast_hash()`

The following new filters have been introduced:

* `password_needs_rehash`
* `wp_hash_password_algorithm`
* `wp_hash_password_options`

Props ayeshrajans, bgermann, dd32, deadduck169, desrosj, haozi, harrym, iandunn, jammycakes, joehoyle, johnbillion, mbijon, mojorob, mslavco, my1xt, nacin, otto42, paragoninitiativeenterprises, paulkevan, rmccue, ryanhellyer, scribu, swalkinshaw, synchro, th23, timothyblynjacobs, tomdxw, westi, xknown.

Additional thanks go to the Roots team, Soatok, Calvin Alkan, and Raphael Ahrens.

Fixes #21022, #44628
Built from https://develop.svn.wordpress.org/trunk@59828


git-svn-id: http://core.svn.wordpress.org/trunk@59170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-17 11:24:21 +00:00

122 lines
2.3 KiB
PHP

<?php
/**
* WP_User_Request class.
*
* Represents user request data loaded from a WP_Post object.
*
* @since 4.9.6
*/
#[AllowDynamicProperties]
final class WP_User_Request {
/**
* Request ID.
*
* @since 4.9.6
* @var int
*/
public $ID = 0;
/**
* User ID.
*
* @since 4.9.6
* @var int
*/
public $user_id = 0;
/**
* User email.
*
* @since 4.9.6
* @var string
*/
public $email = '';
/**
* Action name.
*
* @since 4.9.6
* @var string
*/
public $action_name = '';
/**
* Current status.
*
* @since 4.9.6
* @var string
*/
public $status = '';
/**
* Timestamp this request was created.
*
* @since 4.9.6
* @var int|null
*/
public $created_timestamp = null;
/**
* Timestamp this request was last modified.
*
* @since 4.9.6
* @var int|null
*/
public $modified_timestamp = null;
/**
* Timestamp this request was confirmed.
*
* @since 4.9.6
* @var int|null
*/
public $confirmed_timestamp = null;
/**
* Timestamp this request was completed.
*
* @since 4.9.6
* @var int|null
*/
public $completed_timestamp = null;
/**
* Misc data assigned to this request.
*
* @since 4.9.6
* @var array
*/
public $request_data = array();
/**
* Key used to confirm this request.
*
* @since 4.9.6
* @since 6.8.0 The key is now hashed using wp_fast_hash() instead of phpass.
*
* @var string
*/
public $confirm_key = '';
/**
* Constructor.
*
* @since 4.9.6
*
* @param WP_Post|object $post Post object.
*/
public function __construct( $post ) {
$this->ID = $post->ID;
$this->user_id = $post->post_author;
$this->email = $post->post_title;
$this->action_name = $post->post_name;
$this->status = $post->post_status;
$this->created_timestamp = strtotime( $post->post_date_gmt );
$this->modified_timestamp = strtotime( $post->post_modified_gmt );
$this->confirmed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_confirmed_timestamp', true );
$this->completed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_completed_timestamp', true );
$this->request_data = json_decode( $post->post_content, true );
$this->confirm_key = $post->post_password;
}
}