• Resolved m.ibrahim

    (@mibrahim-1)


    Hi,

    I am using JWT plugin to authorize the user.
    https://www.ads-software.com/plugins/jwt-authentication-for-wp-rest-api/

    Simply this plugin generate a JWT token for the user after he logged in with his username and password and then in every api request that need user authorization I send the JWT token and the plugin decode the token and make current user equal to this user.

    I want to cache custom apis that’s related to user eg: “/users/my-invoices”.

    I followed the tutorial in your reply to this question https://www.ads-software.com/support/topic/woocommerce-3-2-6-api-cache/

    it’s working great but I have two problems

    1- How to flush api cache for a specific user for example after he made an order.
    2- When User logged in with a new token.
    3- Is there a hook that allow me to change the request_headers to be the user id instead of the token before save data to redis.

    • This topic was modified 4 years, 9 months ago by m.ibrahim.
Viewing 1 replies (of 1 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @mibrahim-1

    Thank you for using our plugin!

    Unfortunately at the moment we do not really have any hooks or functions that would work for you.

    1. Flush api cache for a specific user: You would have to find the caches for a specific user, so you would have to find them by request header. However the way we have implemented it, the request headers were never intended to be used as a means to find the cache record. They are stored as a json encoded string, so hard to query by.
    2. Even without the limitations as mentioned under 1, this would be difficult, because you would have to have the old token to find the correct cache records.
    3. No there isn’t any hook for that, if it weren’t for the limitations as mentioned under 1. we could have considered adding such a hook, but at the moment I don’t think there is any use for it?

    The correct implementation of such a plugin in combination with our caching isn’t that easy. We did have some plans to implement an addon for this specific plugin, but that was a long-term plan which has now been postponed even further because of plans to implement WP REST API authentication into WordPress core: https://github.com/wp-api/authentication

Viewing 1 replies (of 1 total)
  • The topic ‘JWT Token Support’ is closed to new replies.