As a newcomer to server scripts, I am facing an issue that I believe has a simple solution, although I have been unable to find the answer so far. My current setup involves using azure mobile services for retrieving and inputting user information, with a focus on preventing users from accessing each other's ID numbers.
In order to retrieve data, the program sends the following HTTP request:
"GET http://Servicename.net/tables/TableName?$top=1&$orderby=__createdAt%20desc&$filter=id+eq+'"+id+"' HTTP/1.1"
The 'id' parameter is based on the user account currently logged in. However, it is essential to prevent users from tampering with the request to view all IDs by sending a query like this:
"GET http://Servicename.net/tables/TableName HTTP/1.1"
To address this issue, my goal is to utilize server-side scripts, specifically focusing on the read operation script, to verify that each request contains a valid ID and only return data associated with that particular ID.
I have attempted the following code snippet:
function read(query, user, request) {
if(request.parameter.id != null){
request.execute();
}
}
However, this approach has not yielded the desired results. Therefore, my question pertains to how I can extract the ID number from the HTTP request and incorporate it effectively within the script. Your assistance in clarifying this matter would be greatly appreciated!