File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -370,10 +370,19 @@ public static function is_refresh_token() {
370370 */
371371 protected static function authenticate_user ( $ username , $ password ) {
372372
373- /**
374- * Try to authenticate the user with the passed credentials
375- */
376- $ user = wp_authenticate ( sanitize_user ( $ username ), trim ( $ password ) );
373+ if ( defined ( 'GRAPHQL_JWT_AUTH_SET_COOKIES ' ) && ! empty ( GRAPHQL_JWT_AUTH_SET_COOKIES ) && GRAPHQL_JWT_AUTH_SET_COOKIES ) {
374+ $ credentials = [
375+ 'user_login ' => sanitize_user ( $ username ),
376+ 'user_password ' => trim ( $ password ),
377+ 'remember ' => false ,
378+ ];
379+
380+ // Try to authenticate the user with the passed credentials, log him in and set cookies
381+ $ user = wp_signon ( $ credentials , true );
382+ } else {
383+ // Try to authenticate the user with the passed credentials
384+ $ user = wp_authenticate ( sanitize_user ( $ username ), trim ( $ password ) );
385+ }
377386
378387 /**
379388 * If the authentication fails return a error
You can’t perform that action at this time.
0 commit comments