You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'description' => __( 'A JWT token that can be used in future requests for authentication/authorization', 'wp-graphql-jwt-authentication' ),
69
-
'resolve' => function ( User$user ) {
70
-
$user = get_user_by( 'id', $user->ID );
71
-
72
-
// Get the token for the user.
73
-
$token = Auth::get_token( $user );
74
-
75
-
// If the token cannot be returned, throw an error.
76
-
if ( empty( $token ) || is_wp_error( $token ) ) {
77
-
thrownewUserError( __( 'The JWT token could not be returned', 'wp-graphql-jwt-authentication' ) );
78
-
}
79
-
80
-
return ! empty( $token ) ? $token : null;
81
-
},
82
-
];
83
-
84
-
$fields['jwtRefreshToken'] = [
85
-
'type' => $type_registry->get_type( 'String' ),
86
-
'description' => __( 'A JWT token that can be used in future requests to get a refreshed jwtAuthToken. If the refresh token used in a request is revoked or otherwise invalid, a valid Auth token will NOT be issued in the response headers.', 'wp-graphql-jwt-authentication' ),
87
-
'resolve' => function ( User$user ) {
88
-
$user = get_user_by( 'id', $user->ID );
89
-
90
-
// Get the token for the user.
91
-
$token = Auth::get_refresh_token( $user );
92
-
93
-
// If the token cannot be returned, throw an error.
94
-
if ( empty( $token ) || is_wp_error( $token ) ) {
95
-
thrownewUserError( __( 'The JWT token could not be returned', 'wp-graphql-jwt-authentication' ) );
96
-
}
97
-
98
-
return ! empty( $token ) ? $token : null;
99
-
},
100
-
];
101
-
102
-
$fields['jwtUserSecret'] = [
103
-
'type' => $type_registry->get_type( 'String' ),
104
-
'description' => __( 'A unique secret tied to the users JWT token that can be revoked or refreshed. Revoking the secret prevents JWT tokens from being issued to the user. Refreshing the token invalidates previously issued tokens, but allows new tokens to be issued.', 'wp-graphql' ),
105
-
'resolve' => function ( User$user ) {
106
-
// Get the user's JWT Secret.
107
-
$secret = Auth::get_user_jwt_secret( $user->ID );
108
-
109
-
// If the secret cannot be returned, throw an error.
110
-
if ( is_wp_error( $secret ) ) {
111
-
thrownewUserError( __( 'The user secret could not be returned', 'wp-graphql-jwt-authentication' ) );
112
-
}
113
-
114
-
// Return the secret.
115
-
return ! empty( $secret ) ? $secret : null;
116
-
},
117
-
];
118
-
119
-
$fields['jwtAuthExpiration'] = [
120
-
'type' => $type_registry->get_type( 'String' ),
121
-
'description' => __( 'The expiration for the JWT Token for the user. If not set custom for the user, it will use the default sitewide expiration setting', 'wp-graphql-jwt-authentication' ),
'description' => __( 'Whether the JWT User secret has been revoked. If the secret has been revoked, auth tokens will not be issued until an admin, or user with proper capabilities re-issues a secret for the user.', 'wp-graphql-jwt-authentication' ),
'description' => __( 'A JWT token that can be used in future requests for authentication/authorization', 'wp-graphql-jwt-authentication' ),
80
+
'resolve' => function ( $user ) {
81
+
$user = get_user_by( 'id', $user->ID );
82
+
83
+
// Get the token for the user.
84
+
$token = Auth::get_token( $user );
85
+
86
+
// If the token cannot be returned, throw an error.
87
+
if ( empty( $token ) || is_wp_error( $token ) ) {
88
+
thrownewUserError( __( 'The JWT token could not be returned', 'wp-graphql-jwt-authentication' ) );
89
+
}
90
+
91
+
return ! empty( $token ) ? $token : null;
92
+
},
93
+
],
94
+
'jwtRefreshToken' => [
95
+
'type' => 'String',
96
+
'description' => __( 'A JWT token that can be used in future requests to get a refreshed jwtAuthToken. If the refresh token used in a request is revoked or otherwise invalid, a valid Auth token will NOT be issued in the response headers.', 'wp-graphql-jwt-authentication' ),
97
+
'resolve' => function ( $user ) {
98
+
$user = get_user_by( 'id', $user->ID );
99
+
100
+
// Get the token for the user.
101
+
$token = Auth::get_refresh_token( $user );
102
+
103
+
// If the token cannot be returned, throw an error.
104
+
if ( empty( $token ) || is_wp_error( $token ) ) {
105
+
thrownewUserError( __( 'The JWT token could not be returned', 'wp-graphql-jwt-authentication' ) );
106
+
}
107
+
108
+
return ! empty( $token ) ? $token : null;
109
+
},
110
+
],
111
+
'jwtUserSecret' => [
112
+
'type' => 'String',
113
+
'description' => __( 'A unique secret tied to the users JWT token that can be revoked or refreshed. Revoking the secret prevents JWT tokens from being issued to the user. Refreshing the token invalidates previously issued tokens, but allows new tokens to be issued.', 'wp-graphql' ),
114
+
'resolve' => function ( $user ) {
115
+
// Get the user's JWT Secret.
116
+
$secret = Auth::get_user_jwt_secret( $user->ID );
117
+
118
+
// If the secret cannot be returned, throw an error.
119
+
if ( is_wp_error( $secret ) ) {
120
+
thrownewUserError( __( 'The user secret could not be returned', 'wp-graphql-jwt-authentication' ) );
121
+
}
122
+
123
+
// Return the secret.
124
+
return ! empty( $secret ) ? $secret : null;
125
+
},
126
+
],
127
+
'jwtAuthExpiration' => [
128
+
'type' => 'String',
129
+
'description' => __( 'The expiration for the JWT Token for the user. If not set custom for the user, it will use the default sitewide expiration setting', 'wp-graphql-jwt-authentication' ),
'description' => __( 'Whether the JWT User secret has been revoked. If the secret has been revoked, auth tokens will not be issued until an admin, or user with proper capabilities re-issues a secret for the user.', 'wp-graphql-jwt-authentication' ),
0 commit comments