All of my Wordpress AJAX requests returns html page for subscribers. Why? - database

I have my ajax post calls from to create post by users under a custom post. I have used the action hook in all works fine for admins. But when a subscriber uses the same, it returns a html but not the response.
But the server-side is working fine on the ajax call. Meaning, the post has been created successfully and the mail also has been sent as expected (as per the code).
I have defined the ajax action hook for both prev and nonprev users.
add_action('wp_ajax_register_participant', 'register_participant_callback');
add_action('wp_ajax_nopriv_register_participant', 'register_participant_callback');
I have also defined the capability type and map_meta_cap while registering the custom post type and set the permission to edit, update and delete the 'registration' post type.
'capability_type'=> 'registration',
'map_meta_cap' => true,
It was actually working fine but suddenly stopped working on all my ajax calls.
Any suggestions to debug?

Related

Post request to logic app from action group

I am trying to send an email alert when certain conditions are met by creating an alert rule in Azure monitor. For this, I also created an action group which tells what action to take when trigger conditions are met. In logic app I am using dynamic content which will come through POST http request, but in action group on azure portal I don't see any option to populate those parameters for POST request. Can anybody help me how to make a post request with request parameters to logic app in Azure portal?
There is no need to send parameters from Action group to logic app. When an action group is tested or the condition satisfied, automatically details will come in Http post request. Using expressions, you can retrieve details from Http post request to use in next action.
I have reproduced issue from my side. Below are steps I followed,
Created Action group in Azure monitor and added action type as Logic App.
Created logic app as shown below,
In Send Email action, I have used dynamic content from Http request trigger as shown below,
When I test action group, It triggered logic app and run details are shown below,
Output of Http trigger:
Send email Action:
5. As You can see in above picture, I am not getting values in Send email action.
So tried with writing expression instead of using dynamic content to get data from http trigger as shown below,
triggerbody()?['data']?['essentials']?['monitorCondition']
triggerbody()?['data']?['essentials']?['fireDateTime']
7. Tested logic app again and getting values as shown below,
Refer to this MS Doc for more information

OKTA Delete user session API is failing in angularjs

I am using OKTA default APIs( /api/v1/users/${userId}/sessions) for closing session across all the devices. The functionality is working as expected but the status is showing the API call is failed.
And also when we validate through Postman the 204 response code is returning but in angularjs the API call is failing.
Below is the API reference page which I have used in my application
https://developer.okta.com/docs/reference/api/users/#user-sessions
Please find the attached screenshot for your reference
Postman Response
There are few OKTA APIs which will support backend only for security reasons. So I have added client.endAllUserSessions(user.id)" method in my backend to remove user session across all devices. It is working fine for me.
(/api/v1/users/${userId}/sessions) API is failed in front end So we should call the "client.endAllUserSessions(user.id)" method in backend(Node JS) to clear user session.
For older okta-sdk-nodejs versions We Should call "client.endAllUserSessions(user.id)" method. For latest okta-sdk-nodejs versions We Should call "client.clearUserSessions(user.id)" method.
Thanks,
Subash.E

how to setup confirm email http post request with react-admin

I have an api method on the backend that confirms the user email (POST request), how can I consume this api with react-admin? I am new to the framework and all I see is consuming CRUD operations(create, list, update and delete).
Nothing stops you from accessing your API with fetch from your own component. If you want you can use some helpers the react-admin team has provided as fetchUtils.
Already shown how here under the EDIT 2 part.

Why am I receiving a 401 Unauthorized error when requesting API data from React?

To make a long story short, I'm building a server-rendered Express / React application and I'm trying to query the back-end, from the client, for some data. The basic flow looks like this:
User navigates to a client path applications/:id
The Application component is loaded
A GET request is made to the server's API from the Application component lifecycle method componentWillMount
The data from the response is added to Redux
The problem is that the response (step 4) is a 401 (Unauthorized). This is not an issue of being logged in or not. A valid session exists and if I navigate to the API route from the browser, I can see the expected response. As an added note, this application is similar to another application (in nearly ever relevant aspect), which does not have this issue.
Attempted troubleshooting steps:
Verified correct modules and versions
Verified correct API request path and configuration (using Axios and withCredentials config param)
Verified server routing and authentication
Verified PassportJS config
Verified the request session is being lost in the auth process
As it turns out, the problem was that I was making the API request from the componentWillMount React lifecycle method. In other words, since the component in question was being rendered on the server and wasn't yet complete, the API call was being made from the server side as well (the component had not yet mounted), meaning the cookie was not available for the API request. Hence the 401 Unauthorized error.
Reading the docs first would have saved me quite a bit of trouble:
componentWillMount() ...
Avoid introducing any side-effects or subscriptions in this method. For those use cases, use componentDidMount() instead.
This is the only lifecycle hook called on server rendering.

working with $http.post function

I want to save data using AngularJS and RestApi. I am sending an object in data parameter.
I tried both $http.post() direct method and $http() method , but non of these are working.
Always the error coming is "Method not allowed-405"
I am running on local machine.
Edit:
Eventually by doing some modifications like I specified "localhost:xxx" before the 'api/abc', now I am getting the error as "The requested resource does not support the http method 'POST'".
The reason is that the API you're using does not support POST requests to the URL you're trying to POST to
More info from http://www.checkupdown.com/status/E405.html below
All Web servers can be configured to allow or disallow any method. For example if a Web server is 'read-only' (no client can modify URL resources on the Web server), then it could be set up to disallow the PUT and DELETE methods. Similarly if there is no user input (all the Web pages are static), then the POST method could be disallowed. So 405 errors can arise because the Web server is not configured to take data from the client at all.

Resources