File tree Expand file tree Collapse file tree 6 files changed +77
-11
lines changed
vendor-prefixed/firebase/php-jwt/src Expand file tree Collapse file tree 6 files changed +77
-11
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,10 @@ public static function register() {
228228 return array_values ( \WC_Payment_Tokens::get_customer_tokens ( $ source ->ID ) );
229229 }
230230
231+ if ( get_current_user_id () === 0 ) {
232+ return [];
233+ }
234+
231235 throw new UserError ( __ ( 'Not authorized to view this user \'s payment methods. ' , 'wp-graphql-woocommerce ' ) );
232236 },
233237 ],
@@ -244,6 +248,10 @@ static function ( $token ) {
244248 );
245249 }
246250
251+ if ( get_current_user_id () === 0 ) {
252+ return [];
253+ }
254+
247255 throw new UserError ( __ ( 'Not authorized to view this user \'s payment methods. ' , 'wp-graphql-woocommerce ' ) );
248256 },
249257 ],
@@ -260,6 +268,10 @@ static function ( $token ) {
260268 );
261269 }
262270
271+ if ( get_current_user_id () === 0 ) {
272+ return [];
273+ }
274+
263275 throw new UserError ( __ ( 'Not authorized to view this user \'s payment methods. ' , 'wp-graphql-woocommerce ' ) );
264276 },
265277 ],
Original file line number Diff line number Diff line change 88
99namespace WPGraphQL \WooCommerce \Vendor \Firebase \JWT ;
1010
11- class BeforeValidException extends \UnexpectedValueException
11+ class BeforeValidException extends \UnexpectedValueException implements JWTExceptionWithPayloadInterface
1212{
13+ private object $ payload ;
14+
15+ public function setPayload (object $ payload ): void
16+ {
17+ $ this ->payload = $ payload ;
18+ }
19+
20+ public function getPayload (): object
21+ {
22+ return $ this ->payload ;
23+ }
1324}
Original file line number Diff line number Diff line change 88
99namespace WPGraphQL \WooCommerce \Vendor \Firebase \JWT ;
1010
11- class ExpiredException extends \UnexpectedValueException
11+ class ExpiredException extends \UnexpectedValueException implements JWTExceptionWithPayloadInterface
1212{
13+ private object $ payload ;
14+
15+ public function setPayload (object $ payload ): void
16+ {
17+ $ this ->payload = $ payload ;
18+ }
19+
20+ public function getPayload (): object
21+ {
22+ return $ this ->payload ;
23+ }
1324}
Original file line number Diff line number Diff line change @@ -159,23 +159,29 @@ public static function decode(
159159 // Check the nbf if it is defined. This is the time that the
160160 // token can actually be used. If it's not yet that time, abort.
161161 if (isset ($ payload ->nbf ) && floor ($ payload ->nbf ) > ($ timestamp + static ::$ leeway )) {
162- throw new BeforeValidException (
162+ $ ex = new BeforeValidException (
163163 'Cannot handle token with nbf prior to ' . \date (DateTime::ISO8601 , (int ) $ payload ->nbf )
164164 );
165+ $ ex ->setPayload ($ payload );
166+ throw $ ex ;
165167 }
166168
167169 // Check that this token has been created before 'now'. This prevents
168170 // using tokens that have been created for later use (and haven't
169171 // correctly used the nbf claim).
170172 if (!isset ($ payload ->nbf ) && isset ($ payload ->iat ) && floor ($ payload ->iat ) > ($ timestamp + static ::$ leeway )) {
171- throw new BeforeValidException (
173+ $ ex = new BeforeValidException (
172174 'Cannot handle token with iat prior to ' . \date (DateTime::ISO8601 , (int ) $ payload ->iat )
173175 );
176+ $ ex ->setPayload ($ payload );
177+ throw $ ex ;
174178 }
175179
176180 // Check if this token has expired.
177181 if (isset ($ payload ->exp ) && ($ timestamp - static ::$ leeway ) >= $ payload ->exp ) {
178- throw new ExpiredException ('Expired token ' );
182+ $ ex = new ExpiredException ('Expired token ' );
183+ $ ex ->setPayload ($ payload );
184+ throw $ ex ;
179185 }
180186
181187 return $ payload ;
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * @license BSD-3-Clause
4+ *
5+ * Modified by Geoff Taylor using Strauss.
6+ * @see https://github.com/BrianHenryIE/strauss
7+ */
8+ namespace WPGraphQL \WooCommerce \Vendor \Firebase \JWT ;
9+
10+ interface JWTExceptionWithPayloadInterface
11+ {
12+ /**
13+ * Get the payload that caused this exception.
14+ *
15+ * @return object
16+ */
17+ public function getPayload (): object ;
18+
19+ /**
20+ * Get the payload that caused this exception.
21+ *
22+ * @param object $payload
23+ * @return void
24+ */
25+ public function setPayload (object $ payload ): void ;
26+ }
You can’t perform that action at this time.
0 commit comments