0

I'm using Kinvey; specifically, a Business Logic Custom Endpoint.

In a business logic custom endpoint, it looks like the "request.username" property is ALWAYS the appkey, rather than the user actually sending the request.

How can I get the actual username of the requesting user (from the authorization header)?

Code:

function onRequest(request, response, modules){
  // Get username
  var username = request.username; 
}

In this code sample, "request.username" is always equal to the appkey, regardless of the authorization header in the true request.

The reason I need the true user is that I'm inserting a data row, and I need the "creator" value in the "_acl" column to be equal to the true user's "_id". Currently, it's always set to the appkey.

1 Answer 1

1

probably too late for you @RyanHenderson, but if someone else comes across this; the appropriate way to do this is to use the collectionAccess module:

var collectionAccess = modules.collectionAccess;
creatorId = collectionAccess.objectID(entity._acl.creator);
collectionAccess.collection('user').findOne({"_id" : creatorId}, function (err, userColl) {
   // ..do stuff with userColl
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.