function login(options) {
                return new Promise(function (resolve, reject) {
                    // Uses the options args style, with success and error callbacks.
                    // The top layer of kbase widgets do not have Q available.

                    // Validate params.
                    if (!options.username || options.username.length === 0) {
                        reject('Username is empty: It is required for login');
                        //  options.error('Username is empty: It is required for login');
                        return;
                    }
                    if (!options.password || options.password.length === 0) {
                        reject('Password is empty: It is required for login');
                        //options.error('Password is empty: It is required for login');
                        return;
                    }

                    // NB: the cookie param determines whether the auth service will
                    // set a cookie or not. The cookie set only includes un and kbase_sessionid.
                    // It does not include the auth token, amazingly, which is required for all 
                    // service calls.
                    var loginParams = {
                        user_id: options.username,
                        password: options.password,
                        fields: 'un,token,user_id,kbase_sessionid,name',
                        status: 1
                    };

                    $.support.cors = true;
                    $.ajax({
                        type: 'POST',
                        url: loginUrl,
                        data: loginParams,
                        dataType: 'json',
                        crossDomain: true,
                        xhrFields: {
                            withCredentials: true
                        },
                        beforeSend: function (xhr) {
                            // make cross-site requests
                            xhr.withCredentials = true;
                        },
                        success: function (data, res, jqXHR) {
                            if (data.kbase_sessionid) {
                                setSession(importFromAuthObject(data));
                                if (!options.disableCookie) {
                                    setSessionCookie();
                                }
                                // options.success(makeKBaseSession());
                                resolve(makeKbaseSession());
                            } else {
                                reject(data.error_msg);
                                //options.error({
                                //    status: 0,
                                //    message: data.error_msg
                                //});
                            }
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            /* Some error cases
                             * status == 401 - show "uid/pw = wrong!" message
                             * status is not 401,
                             *     and we have a responseJSON - if that's the "LoginFailure: Auth fail" error, show the same uid/pw wrong msg.
                             *     and we do not have a responseJSON (or it's something else): show a generic message
                             */
                            var errmsg = textStatus;
                            var wrongPwMsg = "The login attempt failed: Username &amp; Password combination are incorrect";
                            if (jqXHR.status && jqXHR.status === 401) {
                                errmsg = wrongPwMsg;
                            } else if (jqXHR.responseJSON) {
                                // if it has an error_msg field, use it
                                if (jqXHR.responseJSON.error_msg) {
                                    errmsg = jqXHR.responseJSON.error_msg;
                                }
                                // if that's the unclear auth fail message, update it
                                if (errmsg === "LoginFailure: Authentication failed.") {
                                    errmsg = wrongPwMsg;
                                }
                            }
                            // if we get through here and still have a useless error message, update that, too.
                            if (errmsg === "error") {
                                errmsg = "Internal Error: Error connecting to the login server";
                            }
                            sessionObject = null;
                            error = {
                                message: errmsg
                            };
                            // options.error(errmsg);
                            reject(errmsg);
                        }
                    });
                });
            }
/**
             * Authenticate a user give a username and password with the kbase
             * auth service.
             * Named "login" for legacy purposes.
             * 
             * @function login
             * @public
             * 
             * @param {LoginCredentials} options - a authentication credentials, as would
             * be passed in from a login dialog.
             * 
             */
Authenticate a user give a username and password with the kbase
auth service.
Named "login" for legacy purposes.

@function login
@public

@param {LoginCredentials} options - a authentication credentials, as would
be passed in from a login dialog.
Authenticate a user give a username and password with the kbase auth service . Named " login " for legacy purposes . @function login @public @param { LoginCredentials } options - a authentication credentials as would be passed in from a login dialog .
function login(options) {
                return new Promise(function (resolve, reject) {
                    if (!options.username || options.username.length === 0) {
                        reject('Username is empty: It is required for login');
                        return;
                    }
                    if (!options.password || options.password.length === 0) {
                        reject('Password is empty: It is required for login');
                        return;
                    }
                    var loginParams = {
                        user_id: options.username,
                        password: options.password,
                        fields: 'un,token,user_id,kbase_sessionid,name',
                        status: 1
                    };
                    $.support.cors = true;
                    $.ajax({
                        type: 'POST',
                        url: loginUrl,
                        data: loginParams,
                        dataType: 'json',
                        crossDomain: true,
                        xhrFields: {
                            withCredentials: true
                        },
                        beforeSend: function (xhr) {
                            xhr.withCredentials = true;
                        },
                        success: function (data, res, jqXHR) {
                            if (data.kbase_sessionid) {
                                setSession(importFromAuthObject(data));
                                if (!options.disableCookie) {
                                    setSessionCookie();
                                }
                                resolve(makeKbaseSession());
                            } else {
                                reject(data.error_msg);
                            }
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            var errmsg = textStatus;
                            var wrongPwMsg = "The login attempt failed: Username &amp; Password combination are incorrect";
                            if (jqXHR.status && jqXHR.status === 401) {
                                errmsg = wrongPwMsg;
                            } else if (jqXHR.responseJSON) {
                                if (jqXHR.responseJSON.error_msg) {
                                    errmsg = jqXHR.responseJSON.error_msg;
                                }
                                if (errmsg === "LoginFailure: Authentication failed.") {
                                    errmsg = wrongPwMsg;
                                }
                            }
                            if (errmsg === "error") {
                                errmsg = "Internal Error: Error connecting to the login server";
                            }
                            sessionObject = null;
                            error = {
                                message: errmsg
                            };
                            reject(errmsg);
                        }
                    });
                });
            }
function login ( options ) { return new Promise ( function ( resolve , reject ) { if ( ! options . username || options . username . length === 0 ) { reject ( 'Username is empty: It is required for login' ) ; return ; } if ( ! options . password || options . password . length === 0 ) { reject ( 'Password is empty: It is required for login' ) ; return ; } var loginParams = { user_id : options . username , password : options . password , fields : 'un,token,user_id,kbase_sessionid,name' , status : 1 } ; $ . support . cors = true ; $ . ajax ( { type : 'POST' , url : loginUrl , data : loginParams , dataType : 'json' , crossDomain : true , xhrFields : { withCredentials : true } , beforeSend : function ( xhr ) { xhr . withCredentials = true ; } , success : function ( data , res , jqXHR ) { if ( data . kbase_sessionid ) { setSession ( importFromAuthObject ( data ) ) ; if ( ! options . disableCookie ) { setSessionCookie ( ) ; } resolve ( makeKbaseSession ( ) ) ; } else { reject ( data . error_msg ) ; } } , error : function ( jqXHR , textStatus , errorThrown ) { var errmsg = textStatus ; var wrongPwMsg = "The login attempt failed: Username &amp; Password combination are incorrect" ; if ( jqXHR . status && jqXHR . status === 401 ) { errmsg = wrongPwMsg ; } else if ( jqXHR . responseJSON ) { if ( jqXHR . responseJSON . error_msg ) { errmsg = jqXHR . responseJSON . error_msg ; } if ( errmsg === "LoginFailure: Authentication failed." ) { errmsg = wrongPwMsg ; } } if ( errmsg === "error" ) { errmsg = "Internal Error: Error connecting to the login server" ; } sessionObject = null ; error = { message : errmsg } ; reject ( errmsg ) ; } } ) ; } ) ; }
Authenticate a user give a username and password with the kbase
 auth service.
Authenticate a user give a username and password with the kbase auth service .
// Uses the options args style, with success and error callbacks. // The top layer of kbase widgets do not have Q available. // Validate params. //  options.error('Username is empty: It is required for login'); //options.error('Password is empty: It is required for login'); // NB: the cookie param determines whether the auth service will // set a cookie or not. The cookie set only includes un and kbase_sessionid. // It does not include the auth token, amazingly, which is required for all  // service calls. // make cross-site requests // options.success(makeKBaseSession()); //options.error({ //    status: 0, //    message: data.error_msg //}); /* Some error cases
                             * status == 401 - show "uid/pw = wrong!" message
                             * status is not 401,
                             *     and we have a responseJSON - if that's the "LoginFailure: Auth fail" error, show the same uid/pw wrong msg.
                             *     and we do not have a responseJSON (or it's something else): show a generic message
                             */ // if it has an error_msg field, use it // if that's the unclear auth fail message, update it // if we get through here and still have a useless error message, update that, too. // options.error(errmsg);