File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -297,14 +297,16 @@ public static function get_token( $user, $cap_check = true ) {
297
297
298
298
public static function get_refresh_token ( $ user , $ cap_check = true ) {
299
299
300
+ self ::$ is_refresh_token = true ;
301
+
300
302
/**
301
303
* Filter the token signature for refresh tokens, adding the user_secret to the signature and making the
302
304
* expiration long lived so that the token can be used for a long time without the client having to store a new
303
305
* one.
304
306
*/
305
307
add_filter ( 'graphql_jwt_auth_token_before_sign ' , function ( $ token , \WP_User $ user ) {
306
308
$ secret = Auth::get_user_jwt_secret ( $ user ->ID );
307
- if ( ! empty ( $ secret ) && ! is_wp_error ( $ secret ) ) {
309
+ if ( ! empty ( $ secret ) && ! is_wp_error ( $ secret ) && true === self :: is_refresh_token () ) {
308
310
309
311
/**
310
312
* Set the expiration date as a year from now to make the refresh token long lived, allowing the
@@ -313,6 +315,9 @@ public static function get_refresh_token( $user, $cap_check = true ) {
313
315
*/
314
316
$ token ['exp ' ] = apply_filters ( 'graphql_jwt_auth_refresh_token_expiration ' , ( self ::get_token_issued () + ( DAY_IN_SECONDS * 365 ) ) );
315
317
$ token ['data ' ]['user ' ]['user_secret ' ] = $ secret ;
318
+
319
+ self ::$ is_refresh_token = false ;
320
+
316
321
}
317
322
318
323
return $ token ;
You can’t perform that action at this time.
0 commit comments