If the user is logged in in WordPress, I would like to automatically log in the React app with that specific user.
React is trying to get the JWT token with a POST request to https://mysite.com/wp-json/jwt-auth/v1/token and in the form data is setting custom_auth=1.
I tried this:
function mysite_autologin($custom_auth_error, $username, $password, $custom_auth) {
$result = $custom_auth_error;
if (is_user_logged_in()) {
$result = wp_get_current_user();
}
return $result;
}
add_filter( 'jwt_auth_do_custom_auth', 'mysite_autologin', 10, 4);
Unfortunately React always gets a 403 error:
{"success":false,"statusCode":403,"code":"jwt_auth_custom_auth_failed","message":"Custom authentication failed.","data":[]}
Is there any way to expose JWT token if the user has already logged in via WordPress authentication?
Many thanks in advance, all the best.
Marco
Screenshot: https://pasteboard.co/Jzzho55.jpg
LOG
11/19/20 16:31:55.753 [89.64.78.128:14435 1 z7Y] ???? ——POST HTTP/1.1 (HTTPS) /wp-admin/admin-ajax.php
11/19/20 16:31:55.753 [89.64.78.128:14435 1 z7Y] Query String:
11/19/20 16:31:55.753 [89.64.78.128:14435 1 z7Y] HTTP_REFERER: https://kupujemybrzydkiemieszkania.pl/wp-admin/admin.php?page=litespeed-toolbox
11/19/20 16:31:55.753 [89.64.78.128:14435 1 z7Y] Cookie _lscache_vary: 49d9015dcc42368582664aa36119dd98
11/19/20 16:31:55.861 [89.64.78.128:14435 1 z7Y] [Ctrl] X Cache_control -> private ( logged in user )
11/19/20 16:31:55.960 [89.64.78.128:14435 1 z7Y] [Ctrl] X Cache_control -> no Cache ( Admin page )
11/19/20 16:31:56.054 [89.64.78.128:14435 1 z7Y] [Ctrl] not cacheable before ctrl finalize
11/19/20 16:31:56.055 [89.64.78.128:14435 1 z7Y] [Router] get_role: administrator
11/19/20 16:31:56.056 [89.64.78.128:14435 1 z7Y] [Vary] can_change_vary bypassed due to ajax call
11/19/20 16:31:56.057 [89.64.78.128:14435 1 z7Y] [Core] Silence Comment due to REST/AJAX
11/19/20 16:31:56.058 [89.64.78.128:14435 1 z7Y] ???° X-LiteSpeed-Cache-Control: no-cache
11/19/20 16:31:56.059 [89.64.78.128:14435 1 z7Y] [Optm] bypass: Not frontend HTML type
11/19/20 16:31:56.059 [89.64.78.128:14435 1 z7Y] End response
——————————————————————————–
11/19/20 16:31:59.439 [89.64.78.128:14435 1 SNO] ???? ——GET HTTP/1.1 (HTTPS) /
11/19/20 16:31:59.439 [89.64.78.128:14435 1 SNO] Query String:
11/19/20 16:31:59.439 [89.64.78.128:14435 1 SNO] HTTP_REFERER: https://kupujemybrzydkiemieszkania.pl/wp-admin/admin.php?page=litespeed-toolbox
11/19/20 16:31:59.439 [89.64.78.128:14435 1 SNO] Cookie _lscache_vary: 49d9015dcc42368582664aa36119dd98
11/19/20 16:31:59.519 [89.64.78.128:14435 1 SNO] [Ctrl] X Cache_control -> private ( logged in user )
11/19/20 16:31:59.606 [89.64.78.128:14435 1 SNO] [Router] get_role: administrator
11/19/20 16:31:59.621 [89.64.78.128:14435 1 SNO] [Ctrl] X Cache_control init on
11/19/20 16:32:00.396 [89.64.78.128:14435 1 SNO] [Core] Footer hook called
11/19/20 16:32:00.404 [89.64.78.128:14435 1 SNO] [Core] Footer check passed
11/19/20 16:32:00.405 [89.64.78.128:14435 1 SNO] [Vary] set_cookie —> logged-in:1;role:99
11/19/20 16:32:00.406 [89.64.78.128:14435 1 SNO] [Ctrl] X Cache_control -> no Cache ( changing default vary 49d9015dcc42368582664aa36119dd98 => logged-in:1;role:99 )
11/19/20 16:32:00.408 [89.64.78.128:14435 1 SNO] ???° X-LiteSpeed-Cache-Control: no-cache
11/19/20 16:32:00.409 [89.64.78.128:14435 1 SNO] [Core] Footer check passed
11/19/20 16:32:00.410 [89.64.78.128:14435 1 SNO] [Media] finalize
11/19/20 16:32:00.416 [89.64.78.128:14435 1 SNO] [Optm] start
11/19/20 16:32:00.423 [89.64.78.128:14435 1 SNO] [Optm] js defer exclude //ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js?ver=1.12.4
11/19/20 16:32:00.539 [89.64.78.128:14435 1 SNO] ******[Optmer] minify_js failed: JSMin: Unterminated String at byte 6730: “application/json, text/plain, *
11/19/20 16:32:01.080 [89.64.78.128:14435 1 SNO] End response
——————————————————————————–
11/19/20 16:32:21.374 [89.64.78.128:14435 1 BMA] ???? ——POST HTTP/1.1 (HTTPS) /wp-admin/admin.php
11/19/20 16:32:21.374 [89.64.78.128:14435 1 BMA] Query String: page=litespeed-toolbox
11/19/20 16:32:21.374 [89.64.78.128:14435 1 BMA] HTTP_REFERER: https://kupujemybrzydkiemieszkania.pl/wp-admin/admin.php?page=litespeed-toolbox
11/19/20 16:32:21.374 [89.64.78.128:14435 1 BMA] Cookie _lscache_vary: logged-in:1;role:99
11/19/20 16:32:21.490 [89.64.78.128:14435 1 BMA] [Ctrl] X Cache_control -> private ( logged in user )
11/19/20 16:32:21.581 [89.64.78.128:14435 1 BMA] [Router] LSCWP_CTRL: save-settings
11/19/20 16:32:21.581 [89.64.78.128:14435 1 BMA] [Router] LSCWP_CTRL verified: ‘save-settings’
11/19/20 16:32:21.646 [89.64.78.128:14435 1 BMA] [Ctrl] X Cache_control -> no Cache ( Admin page )
11/19/20 16:32:21.647 [89.64.78.128:14435 1 BMA] [Settings] saving
11/19/20 16:32:21.658 [89.64.78.128:14435 1 BMA] a????? posting to : https://api.quic.cloud/d/sync_conf
11/19/20 16:32:22.096 [89.64.78.128:14435 1 BMA] [Ctrl] not cacheable before ctrl finalize
11/19/20 16:32:22.096 [89.64.78.128:14435 1 BMA] [Router] get_role: administrator
11/19/20 16:32:22.097 [89.64.78.128:14435 1 BMA] ???° X-LiteSpeed-Cache-Control: no-cache
11/19/20 16:32:22.098 [89.64.78.128:14435 1 BMA] [Optm] bypass: Not frontend HTML type
11/19/20 16:32:22.098 [89.64.78.128:14435 1 BMA] End response
——————————————————————————–
I have the pro plugin.
I have unexpected results in frontend.
The author can only sort and view his posts. In wp-admin works fine, but in frontend the logged user (author) can see the posts of other authors.
I have this function that works fine, but in frontend does not.
add_action('pre_get_posts', 'query_set_only_author' );
function query_set_only_author( $wp_query ) {
global $current_user;
if( is_admin() && !current_user_can('edit_others_posts') ) {
$wp_query->set( 'author', $current_user->ID );
add_filter('views_edit-post', 'fix_post_counts');
add_filter('views_upload', 'fix_media_counts');
}
}
Can you help me?
Thanks in advanced
]]>If i check this option in the “add meeting page” only logged users can watch the meeting table, but only in the meeting page. (https://www.omlab.it/wikiparkytv/zoom-meetings/corso-di-riabilitazione/)
If i use shortcode to another page, the informations are in clear.
(https://www.omlab.it/wikiparkytv/)
Can you help me?
Thanks
]]><a>
).
// IF USER IS LOGGED
if ( is_user_logged_in() ) {
?>
<script>
var estrattolibro = document.getElementById("shortcode-b5afccd84b849874ca7fc0ded4bc1c9b");
estrattolibro.parentNode.removeChild(estrattolibro);
</script>
<?php
}
// IF USER IS NOT LOGGED
if ( !is_user_logged_in() ) {
?>
<script>
var nodo = document.getElementsByClassName("has-edge is-page-flip")[0];
nodo.setAttribute("href", "https://www.mywebsite.com/prodotto/in-esclusiva-settimanale/?read-book=156");
var librocompleto = document.getElementById("shortcode-a68fa81bfb7e274873f75fbec325a170");
librocompleto.parentNode.removeChild(librocompleto);
</script>
<?php
}
Thanks for help!
]]>Is it possible in PHP code of a page to insert a test in order to check if the user is logged via “IP Based Login” or via “login + password” ?
Thank you to replay,
Regards,
Bruno Bros
Seems like I can’t use this option to “update” my profile, but have to rewrite everyting oO. But I think I probably miss something, it’s too incredible.
Thanks to all
]]>