简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM