[open-ils-commits] [GIT] Evergreen ILS branch master updated. d18e97ff448c581c27605b6a2fe453e55191ce36

Evergreen Git git at git.evergreen-ils.org
Wed Jan 11 17:06:37 EST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  d18e97ff448c581c27605b6a2fe453e55191ce36 (commit)
      from  37d0436d26c027547fe5306e77e2c8fb35714a0e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d18e97ff448c581c27605b6a2fe453e55191ce36
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Wed Jan 11 14:41:15 2012 -0500

    Support auto-login in staff client
    
    By adding three new command line parameters:
    
    -ILSuser - Username to log in with
    -ILSpassword - Password to use
    -ILShost - hostname to use
    
    If, and only if, all three are specified *and* we think we have an already
    registered workstation for the hostname do we trigger an auto login.
    
    Otherwise we just fill everything in and wait for the user.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.js b/Open-ILS/xul/staff_client/chrome/content/main/main.js
index c6b8b8d..73983c3 100644
--- a/Open-ILS/xul/staff_client/chrome/content/main/main.js
+++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js
@@ -691,6 +691,13 @@ function main_init() {
             document.getElementById('offline_import_btn').disabled = true;
         }
 
+        // Attempt auto-login, if provided
+        if("arguments" in window && window.arguments.length > 0 && window.arguments[0].wrappedJSObject != undefined && window.arguments[0].wrappedJSObject.loginInfo != undefined) {
+            auto_login(window.arguments[0].wrappedJSObject.loginInfo);
+            // Regardless of success, clear that variable now, so we don't possibly have passwords hanging around.
+            window.arguments[0].wrappedJSObject.loginInfo = null;
+        }
+
     } catch(E) {
         var error = offlineStrings.getFormattedString('common.exception', [E, '']);
         try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
@@ -742,4 +749,14 @@ function handle_migration() {
     }
 }
 
+function auto_login(loginInfo) {
+    if(G.data.session) return; // We are logged in. No auto-logoff supported.
+    if(loginInfo.host) G.auth.controller.view.server_prompt.value = loginInfo.host;
+    if(loginInfo.user) G.auth.controller.view.name_prompt.value = loginInfo.user;
+    if(loginInfo.passwd) G.auth.controller.view.password_prompt.value = loginInfo.passwd;
+    if(loginInfo.host && loginInfo.user && loginInfo.passwd && G.data.ws_info && G.data.ws_info[loginInfo.host]) {
+        G.auth.login();
+    }
+}
+
 dump('exiting main/main.js\n');
diff --git a/Open-ILS/xul/staff_client/components/clh.js b/Open-ILS/xul/staff_client/components/clh.js
index 9018103..9ef48f3 100644
--- a/Open-ILS/xul/staff_client/components/clh.js
+++ b/Open-ILS/xul/staff_client/components/clh.js
@@ -28,25 +28,30 @@ const clh_category = "m-egcli";
  * @param aChromeURISpec a string specifying the URI of the window to open.
  * @param aArgument an argument to pass to the window (may be null)
  */
-function findOrOpenWindow(aWindowType, aChromeURISpec, aName, aArgument)
+function findOrOpenWindow(aWindowType, aChromeURISpec, aName, aArgument, aLoginInfo)
 {
   var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
     getService(Components.interfaces.nsIWindowMediator);
   var targetWindow = wm.getMostRecentWindow(aWindowType);
   if (targetWindow != null) {
-      if(typeof targetWindow.new_tabs == 'function' && aArgument != null)
-      {
+      var noFocus = false;
+      if(typeof targetWindow.new_tabs == 'function' && aArgument != null) {
           targetWindow.new_tabs(aArgument);
+          noFocus = true;
       }
-      else {
+      if(typeof targetWindow.auto_login == 'function' && aLoginInfo != null) {
+          targetWindow.auto_login(aLoginInfo);
+          noFocus = true;
+      }
+      if(!noFocus) {
           targetwindow.focus;
       }
   }
   else {
     var params = null;
-    if (aArgument != null && aArgument.length != 0)
+    if (aArgument != null && aArgument.length != 0 || aLoginInfo != null)
     {
-        params = { "openTabs" : aArgument };
+        params = { "openTabs" : aArgument, "loginInfo" : aLoginInfo };
         params.wrappedJSObject = params;
     }
     var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
@@ -93,6 +98,8 @@ const myAppHandler = {
     };
 
     var inParams = new Array();
+    var loginInfo = {};
+    var loginInfoProvided = false;
 	var position = 0;
 	while (position < cmdLine.length) {
 		var arg = cmdLine.getArgument(position).toLowerCase();
@@ -106,16 +113,34 @@ const myAppHandler = {
 		  cmdLine.removeArguments(position, position + 1);
 		  continue;
 		}
+        if (arg == '-ilshost' && cmdLine.length > position) {
+          loginInfo.host = cmdLine.getArgument(position + 1);
+          cmdLine.removeArguments(position, position + 1);
+          loginInfoProvided = true;
+          continue;
+        }
+        if (arg == '-ilsuser' && cmdLine.length > position) {
+          loginInfo.user = cmdLine.getArgument(position + 1);
+          cmdLine.removeArguments(position, position + 1);
+          loginInfoProvided = true;
+          continue;
+        }
+        if (arg == '-ilspassword' && cmdLine.length > position) {
+          loginInfo.passwd = cmdLine.getArgument(position + 1);
+          cmdLine.removeArguments(position, position + 1);
+          loginInfoProvided = true;
+          continue;
+        }
 		position=position + 1;
 	}
 
-	if (cmdLine.handleFlag("ILSlogin", false) || inParams.length > 0) {
-	  findOrOpenWindow(WINDOW_MAIN, XUL_MAIN, '_blank', inParams);
+	if (cmdLine.handleFlag("ILSlogin", false) || inParams.length > 0 || loginInfoProvided) {
+	  findOrOpenWindow(WINDOW_MAIN, XUL_MAIN, '_blank', inParams, loginInfoProvided ? loginInfo : null);
 	  cmdLine.preventDefault = true;
 	}
 
     if (cmdLine.handleFlag("ILSoffline", false) || cmdLine.handleFlag("ILSstandalone", false)) {
-   	  findOrOpenWindow(WINDOW_STANDALONE, XUL_STANDALONE, 'Offline', null);
+   	  findOrOpenWindow(WINDOW_STANDALONE, XUL_STANDALONE, 'Offline', null, null);
       cmdLine.preventDefault = true;
    	}
   },
@@ -133,7 +158,11 @@ const myAppHandler = {
              "                       with a 'default' tab\n" +
              "  -ILStab              Open a 'default' tab alone\n" +
              "  -ILSurl <url>        Open the specified url in an Evergreen tab\n" +
-             "  The above six imply -ILSlogin\n" +
+             "  -ILShost             Default hostname for login\n" +
+             "  -ILSuser             Default username for login\n" +
+             "  -ILSpassword         Default password for login\n" +
+             "  The above three, if all specified, trigger an automatic login attempt\n" +
+             "  The above nine imply -ILSlogin\n" +
              "  -ILSlogin            Open the Evergreen Login window\n" +
              "  -ILSstandalone       Open the Evergreen Standalone interface\n" +
              "  -ILSoffline          Alias for -ILSstandalone\n",

-----------------------------------------------------------------------

Summary of changes:
 .../xul/staff_client/chrome/content/main/main.js   |   17 +++++++
 Open-ILS/xul/staff_client/components/clh.js        |   49 ++++++++++++++++----
 2 files changed, 56 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list