Skip to content

Commit 356d705

Browse files
authored
feat: Hooks added to Authorizing URL functionality (#806)
1 parent ac5fa6b commit 356d705

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

includes/type/object/class-customer-type.php

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,14 @@ public static function register_authorizing_url_fields( $fields_to_register ) {
350350
}
351351

352352
// Build nonced url as an unauthenticated user.
353-
$nonce_name = woographql_setting( 'cart_url_nonce_param', '_wc_cart' );
354-
$url = add_query_arg(
355-
[
356-
'session_id' => $customer_id,
357-
$nonce_name => woographql_create_nonce( "load-cart_{$customer_id}" ),
358-
],
353+
$nonce_name = woographql_setting( 'cart_url_nonce_param', '_wc_cart' );
354+
$query_params = [
355+
'session_id' => $customer_id,
356+
$nonce_name => woographql_create_nonce( "load-cart_{$customer_id}" ),
357+
];
358+
$query_params = apply_filters( 'graphql_cart_url_query_params', $query_params, $customer_id, $source );
359+
$url = add_query_arg(
360+
$query_params,
359361
site_url( woographql_setting( 'authorizing_url_endpoint', 'transfer-session' ) )
360362
);
361363

@@ -400,12 +402,14 @@ public static function register_authorizing_url_fields( $fields_to_register ) {
400402
}
401403

402404
// Build nonced url as an unauthenticated user.
403-
$nonce_name = woographql_setting( 'checkout_url_nonce_param', '_wc_checkout' );
404-
$url = add_query_arg(
405-
[
406-
'session_id' => $customer_id,
407-
$nonce_name => woographql_create_nonce( "load-checkout_{$customer_id}" ),
408-
],
405+
$nonce_name = woographql_setting( 'checkout_url_nonce_param', '_wc_checkout' );
406+
$query_params = [
407+
'session_id' => $customer_id,
408+
$nonce_name => woographql_create_nonce( "load-checkout_{$customer_id}" ),
409+
];
410+
$query_params = apply_filters( 'graphql_checkout_url_query_params', $query_params, $customer_id, $source );
411+
$url = add_query_arg(
412+
$query_params,
409413
site_url( woographql_setting( 'authorizing_url_endpoint', 'transfer-session' ) )
410414
);
411415

@@ -454,12 +458,14 @@ public static function register_authorizing_url_fields( $fields_to_register ) {
454458
}
455459

456460
// Build nonced url as an unauthenticated user.
457-
$nonce_name = woographql_setting( 'account_url_nonce_param', '_wc_account' );
458-
$url = add_query_arg(
459-
[
460-
'session_id' => $customer_id,
461-
$nonce_name => woographql_create_nonce( "load-account_{$customer_id}" ),
462-
],
461+
$nonce_name = woographql_setting( 'account_url_nonce_param', '_wc_account' );
462+
$query_params = [
463+
'session_id' => $customer_id,
464+
$nonce_name => woographql_create_nonce( "load-account_{$customer_id}" ),
465+
];
466+
$query_params = apply_filters( 'graphql_account_url_query_params', $query_params, $customer_id, $source );
467+
$url = add_query_arg(
468+
$query_params,
463469
site_url( woographql_setting( 'authorizing_url_endpoint', 'transfer-session' ) )
464470
);
465471

includes/utils/class-protected-router.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ private function process_auth_request() {
363363
$this->redirect_to_home();
364364
}
365365

366+
do_action( 'woographql_process_auth_request_nonce_verified' );
367+
366368
// If Session ID is a user ID authenticate as session user.
367369
if ( 0 !== absint( $session_id ) ) {
368370
$user_id = absint( $session_id );

0 commit comments

Comments
 (0)