Note that there are some explanatory texts on larger screens.

plurals
  1. POExtend User authentication object in Azure Mobile Services
    text
    copied!<p>Is it possible to add additional properties to the User object on the server in WAMS? I would like to store the Id primary key of my User table for (secure) use in my table scripts. At the moment the only id is the vendor specific authentication Id, but I'd like to be able to allow users to choose an authentication method. Currently my (simplified) table design is as follows:</p> <p>User table:</p> <ul> <li>id </li> <li>googleId</li> <li>twitterId</li> <li>facebookId</li> <li>name, etc...</li> </ul> <p>League table</p> <ul> <li>id</li> <li>userId</li> <li>name, etc</li> </ul> <p>I'd like to store the user primary key in the userId field on the league table, and then query it to ensure that users only get to see leagues they created. At the moment, the user object in table scripts sends through a User object with the Google/Twitter/Windows authentication token and I have to do a query to get the primary key userID, everytime I want to carry out an operation on a table with a userId column.</p> <p>Ideal solution would be that when the Insert script on my User table is called on registrations and logins I can do:</p> <pre><code>// PSEUDO CODE function insert(item, user, request) { var appUserId; Query the user table using the user.userId Google/Twitter/Facebook id If user exists { // Set a persisted appUserId to use in all subsequent table scripts. user.appUserId = results.id; } else { Set the GooTwitFace columns on the user table, from user.userId insert the user then get the inserted record id // Set a persisted appUserId to use in all subsequent table scripts user.appUserId = insertUserPK; } } </code></pre> <p>Then, in subsequent table scripts, I'd like to use <code>user.appUserId</code> in queries</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload