locked
Azure Easy table add the email to the context.user RRS feed

  • Question

  • Hi:

    We need to store the email in the context to be able to reuse it during all of our interactions with the Easy Tables to avoid invoking the getIdentity() function in each table.

    I found this javascript:  

    var authCache = {};
     
    function authMiddleware(request, response, next) {
      
      if (typeof request.azureMobile.user !== 'undefined') {
     
        if (typeof authCache[request.azureMobile.user.id] !== 'undefined') {
          
          request.azureMobile.user.emailaddress = authCache[request.azureMobile.user.id];
          next();
        }
        request.azureMobile.user.getIdentity().then(function (userInfo) {
          if (typeof userInfo.microsoftaccount.claims.emailaddress !== 'undefined') {
            authCache[request.azureMobile.user.id] = userInfo.microsoftaccount.claims.emailaddress;
            request.azureMobile.user.emailaddress = authCache[request.azureMobile.user.id];
          }
          next();
        });
      } else {
        next();
      }
      
    }
     
    module.exports = authMiddleware;

    The problem is that once I enabled this in the App.js the Xamarin Forms application that consume this Azure backend starts to fail.  For example, the table read returns no records, but the next time return a record.  Is totally inconsistent.

    Do you have any idea of what could be causing this issue or what strategy can I use to debug this.

    Thanks

    David

    Saturday, September 17, 2016 12:45 AM

Answers

All replies

  • I'd ask them over here.

    https://forums.xamarin.com/

    https://social.msdn.microsoft.com/forums/azure/en-US/home?forum=azuremobile

     

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by pituachMVP Saturday, September 17, 2016 5:20 AM
    • Marked as answer by pituachMVP Monday, September 19, 2016 11:46 AM
    Saturday, September 17, 2016 2:51 AM
  • I think that first link more fit as this for question regarding Xamarin :-)

    signature   Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]    [Linkedin]

    Saturday, September 17, 2016 5:21 AM
  • Thanks I added the question in the other forum.

    Saturday, September 17, 2016 8:59 PM
  • Sounds good, you're welcome.

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Saturday, September 17, 2016 9:10 PM