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

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

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744946631a4602659.html

相关推荐

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

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

    2天前
    70

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信