File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -355,10 +355,23 @@ public static function is_refresh_token() {
355355 */
356356 protected static function authenticate_user ( $ username , $ password ) {
357357
358- /**
359- * Try to authenticate the user with the passed credentials
360- */
361- $ user = wp_authenticate ( sanitize_user ( $ username ), trim ( $ password ) );
358+ if (defined ( 'GRAPHQL_JWT_AUTH_SET_COOKIES ' ) && ! empty ( GRAPHQL_JWT_AUTH_SET_COOKIES ) && GRAPHQL_JWT_AUTH_SET_COOKIES ) {
359+ $ credentials = [
360+ 'user_login ' => sanitize_user ( $ username ),
361+ 'user_password ' => trim ( $ password ),
362+ 'remember ' => false ,
363+ ];
364+
365+ /**
366+ * Try to authenticate the user with the passed credentials, log him in and set cookies
367+ */
368+ $ user = wp_signon ( $ credentials , true );
369+ } else {
370+ /**
371+ * Try to authenticate the user with the passed credentials
372+ */
373+ $ user = wp_authenticate ( sanitize_user ( $ username ), trim ( $ password ) );
374+ }
362375
363376 /**
364377 * If the authentication fails return a error
You can’t perform that action at this time.
0 commit comments