Closed botoxparty closed 1 year ago
I have the same idea, I think you don't storage the token on login, I try to make something and the basic idea and not the best one, I have an script with an ajax to pass the data on login and saving the token on localStorage for example:
add_action('login_footer', 'get_token');
function get_token() { ?>
<script>
your script here
you can get the data with jquery
user = $("#user_login").val();
pass = $("#user_pass").val();
</script>
<?php}
it is not the best way but for test its working for me
@jon1wt Sorry but I'm not really sure what you're talking about.
Of course i'm storing my tokens in localstorage on login? I'm using Angular so i'm not writing any jquery/ajax stuff.
I feel like this issue is more that WP is decommissioning my tokens once the user logs in somewhere else or something.
Sorry, I understood wrong, I think if the same user requests a new token the previous one is invalid, it may be that or that the session is expiring very soon
Yeah something seems to be invalidating the sessions but i'm not sure what it could be.
Will wait for a response from a dev
yes, while you wait, try to change the expiration time and experiment with that
The default is 7 days and I haven't changed it.
Okay so i've been testing it by using the front-end in one browser, then using wp-admin in another browser and I no longer experience this issue.
It must be some kind of cookie conflict. Will keep digging.
Hey,
I'm having an issue where if I had just logged in, then everything works fine, but sometimes if I close the window or return to the site at a later time then WP API doesn't recognise me as a logged in user.
e.g. I have an endpoint that returns the current logged in user's details, sometimes it will return null. The headers are definitely being passed.
Having a hard time debugging this, could the API be using cookies or something and expiring them? This could be an issue with logging into the admin panel as well as through JWT Auth at the same time as the only users I have tried are admin users.
Any ideas or suggestions?