Skip to content

Commit 9282106

Browse files
committed
Store user as part of token
1 parent 255eaa2 commit 9282106

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/class-wp-json-authentication-oauth1.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,22 @@ public function generate_request_token( $params ) {
322322
* @param string $key Token ID
323323
* @return string|WP_Error Verification code on success, error otherwise
324324
*/
325-
public function authorize_request_token( $key ) {
325+
public function authorize_request_token( $key, $user = null ) {
326326
$token = $this->get_request_token( $key );
327327
if ( is_wp_error( $token ) ) {
328328
return $token;
329329
}
330330

331+
if ( empty( $user ) ) {
332+
$user = get_current_user_id();
333+
}
334+
elseif ( is_a( $user, 'WP_User' ) ) {
335+
$user = $user->ID;
336+
}
337+
331338
$token['authorized'] = true;
332339
$token['verifier'] = wp_generate_password( self::VERIFIER_LENGTH, false );
340+
$token['user'] = $user;
333341
$token = apply_filters( 'oauth_request_token_authorized_data', $token );
334342
update_option( 'oauth1_request_' . $key, $token );
335343
return $token['verifier'];

0 commit comments

Comments
 (0)