gocodebox / lifterlms-rest

LifterLMS REST API Feature Plugin
6 stars 7 forks source link

Inform the user that they need to use HTTPS instead of HTTP when usage of HTTP is the problem. #331

Open dominiquemariano opened 5 months ago

dominiquemariano commented 5 months ago

Is your feature request related to a problem? Please describe. The request below returns the following error: code: 'llms_rest_unauthorized_request', message: 'Sorry, you are not allowed to create an enrollment as this user.', when you are using HTTP.

curl "http://lms.local/wp-json/llms/v1/students/2/enrollments/66" \
  -X POST \
  -H "authorization: Basic Y2tfYmFkNzg1ODg4NDEyNTJmYzU5OTI0MzQ0NWY0YzVmZTcwYzlkMjE1OTpjc184ZDNkYTIzNGIwNGY3MWEyN2QwYWI3MGQ0YjUxN2M2Y2JjNDNmY2Zj" 

However, when the same code uses HTTPS as seen below, the error disappears.

curl "https://lms.local/wp-json/llms/v1/students/2/enrollments/66" \
  -X POST \
  -H "authorization: Basic Y2tfYmFkNzg1ODg4NDEyNTJmYzU5OTI0MzQ0NWY0YzVmZTcwYzlkMjE1OTpjc184ZDNkYTIzNGIwNGY3MWEyN2QwYWI3MGQ0YjUxN2M2Y2JjNDNmY2Zj" 

Describe the solution you'd like The error message should make it clear that the user should be using HTTPS instead of HTTP when the usage of HTTP is the source of the problem.

Describe alternatives you've considered None.

Requesting customerr https://wordpress.org/support/topic/how-to-enroll-user-using-the-rest-api/