最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

authentication - REST API: best place to set current user for JWT auth?

programmeradmin1浏览0评论

I've studied a couple of JWT auth plugins and notice the current user is being set in either the rest_api_init action:

add_action( 'rest_api_init', function () {
  wp_set_current_user($token->user_id);
});

Or in the determine_current_user filter:

add_filter( 'determine_current_user', function ($user_id) {
  return $token->user_id;
});

Any advice as to which one is better? I've tested with both and they seem to have the same effectiveness.

发布评论

评论列表(0)

  1. 暂无评论