Current user is not set when sending POST
-
Hi,
Thank you for your previous help getting with CORs… I’m further along, but am running into a new issue, probably related to CORs. I’d be happy to upgrade the plugin, if I can ensure it will work with my AngularJS client.I’m sending the access_token via the query string as documentation suggests when doing a POST (which is not secure? ). But, the current user is not being set/detected when the POST is sent from an AngularJS client (Cross domain) so my POST handling code fails ‘authenticating the user’
NOTE: The access log shows an OPTION and then two POST requests are being sent to the WP server. The first POST request returns a 403 then the second POST returns a 200.
NOTE 2: The current user IS being set correctly when making the same POST api call from POSTMAN. Only one POST request is sent.
NOTE3: Here is debug logging in _wo_authenicate_bypass, when calling POST from AngularJS. I see the_wo_authenicate_bypass is being called multiple times, and the user is initially set but not the call which preceeds before my create_message_permissions_check code runs. Here is the debug log:
[28-Jan-2016 19:21:42 UTC] PHP Notice: Constant REST_API_VERSION already defined in /Users/lynne/freightfinder/wp-content/plugins/rest-api/core/wp-includes/rest-api.php on line 15
[28-Jan-2016 19:21:42 UTC] WO_Server::_wo_authenicate_bypass(1): user_id =
[28-Jan-2016 19:21:42 UTC] WO_Server::_wo_authenicate_bypass (4): loading oauth2
[28-Jan-2016 19:21:42 UTC] WO_Server::_wo_authenicate_bypass(5): verifyResourceRequest is true
[28-Jan-2016 19:21:42 UTC] WO_Server::_wo_authenicate_bypass(6): returning token[user_id] = 1
[28-Jan-2016 19:21:42 UTC] WO_Server::_wo_authenicate_bypass(1): user_id = 1
[28-Jan-2016 19:21:42 UTC] WO_Server::_wo_authenicate_bypass(2): user already logged in.
[28-Jan-2016 19:21:42 UTC] WO_Server::_wo_authenicate_bypass(1): user_id = 1
[28-Jan-2016 19:21:42 UTC] WO_Server::_wo_authenicate_bypass(2): user already logged in.
[28-Jan-2016 19:21:42 UTC] adding ffapi/v1/ routes action
[28-Jan-2016 19:21:43 UTC] PHP Notice: Constant REST_API_VERSION already defined in /Users/lynne/freightfinder/wp-content/plugins/rest-api/core/wp-includes/rest-api.php on line 15
[28-Jan-2016 19:21:47 UTC] PHP Notice: Constant REST_API_VERSION already defined in /Users/lynne/freightfinder/wp-content/plugins/rest-api/core/wp-includes/rest-api.php on line 15
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(1): user_id =
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass (4): loading oauth2
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(5): verifyResourceRequest is true
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(6): returning token[user_id] = 1
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(1): user_id = 1
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(2): user already logged in.
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(1): user_id = 1
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(2): user already logged in.
[28-Jan-2016 19:21:47 UTC] adding ffapi/v1/ routes action
[28-Jan-2016 19:21:47 UTC] PHP Notice: Constant REST_API_VERSION already defined in /Users/lynne/freightfinder/wp-content/plugins/rest-api/core/wp-includes/rest-api.php on line 15
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(1): user_id =
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass (4): loading oauth2
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(1): user_id =
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass (4): loading oauth2
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass(1): user_id =
[28-Jan-2016 19:21:47 UTC] WO_Server::_wo_authenicate_bypass (4): loading oauth2
[28-Jan-2016 19:21:47 UTC] adding ffapi/v1/ routes action
[28-Jan-2016 19:21:47 UTC] Message_Route::create_message_permissions_check Current user is not set.
[28-Jan-2016 19:21:47 UTC] get_messages_permissions_check…
[28-Jan-2016 19:21:47 UTC] Message_Route::create_message_permissions_check Current user is not set.
[28-Jan-2016 19:21:48 UTC] PHP Notice: Constant REST_API_VERSION already defined in /Users/lynne/freightfinder/wp-content/plugins/rest-api/core/wp-includes/rest-api.php on line 15
Thoughts?
Thanks,
Lynne
- The topic ‘Current user is not set when sending POST’ is closed to new replies.