Separate cookie generation from cookie set. Introduce wp_generate_auth_cookie(). see #5367
git-svn-id: https://develop.svn.wordpress.org/trunk@6529 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bee51869ea
commit
d9cfccddc1
@ -357,6 +357,19 @@ function wp_validate_auth_cookie($cookie = '') {
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('wp_generate_auth_cookie') ) :
|
||||
function wp_generate_auth_cookie($user_id, $expiration) {
|
||||
$user = get_userdata($user_id);
|
||||
|
||||
$key = wp_hash($user->user_login . $expiration);
|
||||
$hash = hash_hmac('md5', $user->user_login . $expiration, $key);
|
||||
|
||||
$cookie = $user->user_login . '|' . $expiration . '|' . $hash;
|
||||
|
||||
return apply_filters('auth_cookie', $cookie, $user_id, $expiration);
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('wp_set_auth_cookie') ) :
|
||||
function wp_set_auth_cookie($user_id, $remember = false) {
|
||||
$user = get_userdata($user_id);
|
||||
@ -368,10 +381,7 @@ function wp_set_auth_cookie($user_id, $remember = false) {
|
||||
$expire = 0;
|
||||
}
|
||||
|
||||
$key = wp_hash($user->user_login . $expiration);
|
||||
$hash = hash_hmac('md5', $user->user_login . $expiration, $key);
|
||||
|
||||
$cookie = $user->user_login . '|' . $expiration . '|' . $hash;
|
||||
$cookie = wp_generate_auth_cookie($user_id, $expiration);
|
||||
|
||||
do_action('set_auth_cookie', $cookie, $expire);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user