Skip to content

Commit

Permalink
feat: Hooks added to Authorizing URL functionality (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 authored Sep 23, 2023
1 parent ac5fa6b commit 356d705
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
42 changes: 24 additions & 18 deletions includes/type/object/class-customer-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,14 @@ public static function register_authorizing_url_fields( $fields_to_register ) {
}

// Build nonced url as an unauthenticated user.
$nonce_name = woographql_setting( 'cart_url_nonce_param', '_wc_cart' );
$url = add_query_arg(
[
'session_id' => $customer_id,
$nonce_name => woographql_create_nonce( "load-cart_{$customer_id}" ),
],
$nonce_name = woographql_setting( 'cart_url_nonce_param', '_wc_cart' );
$query_params = [
'session_id' => $customer_id,
$nonce_name => woographql_create_nonce( "load-cart_{$customer_id}" ),
];
$query_params = apply_filters( 'graphql_cart_url_query_params', $query_params, $customer_id, $source );
$url = add_query_arg(
$query_params,
site_url( woographql_setting( 'authorizing_url_endpoint', 'transfer-session' ) )
);

Expand Down Expand Up @@ -400,12 +402,14 @@ public static function register_authorizing_url_fields( $fields_to_register ) {
}

// Build nonced url as an unauthenticated user.
$nonce_name = woographql_setting( 'checkout_url_nonce_param', '_wc_checkout' );
$url = add_query_arg(
[
'session_id' => $customer_id,
$nonce_name => woographql_create_nonce( "load-checkout_{$customer_id}" ),
],
$nonce_name = woographql_setting( 'checkout_url_nonce_param', '_wc_checkout' );
$query_params = [
'session_id' => $customer_id,
$nonce_name => woographql_create_nonce( "load-checkout_{$customer_id}" ),
];
$query_params = apply_filters( 'graphql_checkout_url_query_params', $query_params, $customer_id, $source );
$url = add_query_arg(
$query_params,
site_url( woographql_setting( 'authorizing_url_endpoint', 'transfer-session' ) )
);

Expand Down Expand Up @@ -454,12 +458,14 @@ public static function register_authorizing_url_fields( $fields_to_register ) {
}

// Build nonced url as an unauthenticated user.
$nonce_name = woographql_setting( 'account_url_nonce_param', '_wc_account' );
$url = add_query_arg(
[
'session_id' => $customer_id,
$nonce_name => woographql_create_nonce( "load-account_{$customer_id}" ),
],
$nonce_name = woographql_setting( 'account_url_nonce_param', '_wc_account' );
$query_params = [
'session_id' => $customer_id,
$nonce_name => woographql_create_nonce( "load-account_{$customer_id}" ),
];
$query_params = apply_filters( 'graphql_account_url_query_params', $query_params, $customer_id, $source );
$url = add_query_arg(
$query_params,
site_url( woographql_setting( 'authorizing_url_endpoint', 'transfer-session' ) )
);

Expand Down
2 changes: 2 additions & 0 deletions includes/utils/class-protected-router.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ private function process_auth_request() {
$this->redirect_to_home();
}

do_action( 'woographql_process_auth_request_nonce_verified' );

// If Session ID is a user ID authenticate as session user.
if ( 0 !== absint( $session_id ) ) {
$user_id = absint( $session_id );
Expand Down

0 comments on commit 356d705

Please sign in to comment.