Cilenco
Cilenco

Reputation: 7137

Azure - Data only for the owner

I use an Azure Mobile Serivce to save data from my app useres in my Windows 8 Store App. I want to publish the app in the app store but for this I have to be sure every user can only get his own data. If 10 people upload data to my Azure service they should only be able to get their own data. How can I do this?

Upvotes: 0

Views: 69

Answers (1)

Pascal
Pascal

Reputation: 1141

You should check the Use scripts to authorize users in Mobile Services tutorial it will show you how to partition the data per user

Basically you have to write custom scripts server side (directly in the Azure Portal in the Mobile Service script section) for the Insert operation like this

function insert(item, user, request) {
  item.userId = user.userId;    
  request.execute();
}

And the Read operation like this

function read(query, user, request) {
   query.where({ userId: user.userId });    
   request.execute();
}

But first you will have to add authorization to your app as shown in the Get started with authentication in Mobile Services tutorial

Upvotes: 1

Related Questions