Correction to sample app login code supplied in OE Developme

Posted by mcmann on 14-Mar-2013 14:25

The code on page 55 in the OpenEdge Development: Mobile Applications book inadvertly left out a variable that must be defined in order for the sample application to create a new progress.data.Session.  The variable cMsg needs to be defined and set to "ok" otherwise, the sample appication will not connect and return data.

The correct code is as follows:

var settings;
var cMsg = "ok";
try {
  /* CHANGE THIS TO POINT TO YOUR SETTINGS SERVICE */
  settings = MyMobileService_dsCustomer_Settings;
 
  pdsession = new progress.data.Session();
 
  var loginResult = pdsession.login(settings.serviceURI,"","");
 
  if (loginResult != progress.data.Session.LOGIN_SUCCESS) {
     console.log('ERROR: Login failed with code: ' + loginResult);
     switch (loginResult) {
          case progress.data.Session.LOGIN_AUTHENTICATION_FAILURE:
            cMsg = 'Invalid user-id or password';
            break;
          case progress.data.Session.LOGIN_GENERAL_FAILURE:
          default:
            cMsg = 'Service is unavailable';
            break;
     }
  }
}
catch (e) {
     cMsg = "Failed to log in";
     console.log(e.stack);
}
if (cMsg != "ok") {
   alert(cMsg);
   return;
}
pdsession.addCatalog(settings.catalogURI);

All Replies

This thread is closed