Terminates the login session on the Mobile Web application managed by the current JSDOSession object, and reinitializes most of the state information maintained by the object.
This method throws an exception if it is not possible to send a request to the specified Web application.
On a successful logout, the JSDOSession object sets its connected property to false. If the logout fails, the object leaves its connected property set to true, unless the failure happened because the App cannot access the server.
Once logout( ) is executed, no further communication (other than a login( ) call) can occur between the Mobile App and the server using this JSDOSession object. However, any catalogs loaded in the object remain available to create and maintain JSDOs, though these JSDOs cannot make requests to the server until a new login session is established for the object (including for anonymous access).
Following are the signatures of methods that are observed in the jQuery Promise that logout( ) returns:
Syntax:
done: function ( session , result , info ) fail: function ( session , result , info ) always: function ( session , result , info )
session
A reference to the JSDOSession object on which logout( ) was called.
result
A constant indicating the overall result of the call that can have one of the following values:
progress.data.Session.SUCCESS — The logout completed successfully.
progress.data.Session.GENERAL_FAILURE — User logout failed because of some error.
info
A JavaScript object that can have the following properties:
errorObject — Any error object thrown while attempting to terminate the login session.
xhr — A reference to the XMLHttpRequest object sent to the Web server to terminate the user login session.
Detailed logout behavior
When this method terminates the associated login session, the JSDOSession object can be re-used to start a new session using the same serviceURI and authenticationModel configuration settings originally passed to the object's constructor. The JSDOSession object's properties retain their values from the previous login session, with the following exceptions:
clientContextId is reset to null.
loginHttpStatus is reset to null.
loginResult is reset to null.
userName is reset to null.
Existing JSDOs and catalog information are not affected by a successful execution of logout( ). However, any attempt to call addCatalog( or a JSDO method that requires contacting the server results in an error object being thrown.
Example
The following code fragment calls the logout( ) method on the JSDOsession object, empSession. This example uses try and catch blocks in case logout( ) throws an unexpected error object, and displays messages accordingly:
var msg;
try { empSession.logout( ).done( function( session, result, info ) { msg = "Logged out successfully”; }).fail( function( session, result, info ) { if ( result === progress.data.Session.GENERAL_FAILURE ) { msg = "Employee Logout failed. Unspecified error"; if ( info.errorObject ) { // Process error object thrown during logout . . . } if ( info.xhr ) { // Process XHR sent during logout . . . } else { msg = "Unexpected logout result"; if ( info.errorObject ) { // Process error object thrown during logout . . . } // Process info.xhr, if necessary, for more information } }); alert(msg); } catch(errObj) { msg = errObj ? '\n' + errObj.message : ''; alert("There was an unexpected error attempting log out." + msg); }