Skip to content

Commit 82b48c2

Browse files
authored
Use different transients for live and test oauth state validations (#3335)
1 parent 771a8e9 commit 82b48c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

includes/connect/class-wc-stripe-connect.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function get_oauth_url( $return_url = '', $mode = 'live' ) {
5656
return $result;
5757
}
5858

59-
set_transient( 'wcs_stripe_connect_state', $result->state, 6 * HOUR_IN_SECONDS );
59+
set_transient( 'wcs_stripe_connect_state_' . $mode, $result->state, 6 * HOUR_IN_SECONDS );
6060

6161
return $result->oauthUrl; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
6262
}
@@ -74,7 +74,7 @@ public function connect_oauth( $state, $code, $mode = 'live' ) {
7474
// The state parameter is used to protect against CSRF.
7575
// It's a unique, randomly generated, opaque, and non-guessable string that is sent when starting the
7676
// authentication request and validated when processing the response.
77-
if ( get_transient( 'wcs_stripe_connect_state' ) !== $state ) {
77+
if ( get_transient( 'wcs_stripe_connect_state_' . $mode ) !== $state ) {
7878
return new WP_Error( 'Invalid state received from Stripe server' );
7979
}
8080

@@ -84,7 +84,7 @@ public function connect_oauth( $state, $code, $mode = 'live' ) {
8484
return $response;
8585
}
8686

87-
delete_transient( 'wcs_stripe_connect_state' );
87+
delete_transient( 'wcs_stripe_connect_state_' . $mode );
8888

8989
return $this->save_stripe_keys( $response, $mode );
9090
}

0 commit comments

Comments
 (0)