Operator Change Fun
authorThomas Berezansky <tsbere@mvlc.org>
Thu, 12 Apr 2012 14:23:12 +0000 (10:23 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 1 Aug 2012 20:14:45 +0000 (16:14 -0400)
Allow for temporary, staff, and permanent operator changes.

Temporary uses a temp authtoken for a few minute timeout.

Staff uses a normal staff login authtoken for a multi-hour timeout.

Permanent is a staff change that disregards the previous login instead of
allowing it to be recovered by using the menu item again.

I also fixed things up so later timeouts can re-use the previous duration
and fixed up some title bar issues:

1 - Login screen shows version again (needed a document in the title set)
2 - Menu windows don't forget the server name
3 - Menu windows keep the same number for their lifetime

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Bill Erickson <berick@esilibrary.com>

Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/main/main.js
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/content/main/menu_frame.xul
Open-ILS/xul/staff_client/chrome/content/util/network.js
Open-ILS/xul/staff_client/server/main/simple_auth.xul

index 4ad7f61..c67c1b6 100644 (file)
 <!ENTITY staff.auth.verify.submit.accesskey "V">
 <!ENTITY staff.auth.verify.retrieve.label "Retrieve">
 <!ENTITY staff.auth.verify.retrieve.accesskey "R">
+<!ENTITY staff.auth.change_type.label "New Login Type:">
+<!ENTITY staff.auth.change_type.accesskey "N">
+<!ENTITY staff.auth.change_type_description "Temporary logins expire with a few minutes of inactivity. Staff logins are the same as the initial login into the staff client. Permanent will discard the existing login session and replace it with the new one.">
+<!ENTITY staff.auth.change_type_staff "Staff">
+<!ENTITY staff.auth.change_type_temporary "Temporary">
+<!ENTITY staff.auth.change_type_permanent "Permanent">
 
 <!ENTITY staff.bills_current_payment_label "Current Payment">
 <!ENTITY staff.bills_information "Information">
index 44d7f72..c131bbe 100644 (file)
@@ -586,7 +586,7 @@ function main_init() {
             }
         }
 
-        window.title = authStrings.getFormattedString('staff.auth.titlebar.label', version);
+        window.document.title = authStrings.getFormattedString('staff.auth.titlebar.label', CLIENT_VERSION);
         var x = document.getElementById('about_btn');
         x.addEventListener(
             'command',
index 8d130f4..1ef0da6 100644 (file)
@@ -1284,13 +1284,18 @@ main.menu.prototype = {
                         } else {
                             if (network.get_new_session(offlineStrings.getString('menu.cmd_chg_session.label'),{'url_prefix':obj.url_prefix})) {
                                 obj.data.stash_retrieve();
-                                obj.data.list.au[1] = JSON2js( temp_au );
-                                obj.data.stash('list');
-                                obj.data.previous_session = JSON2js( temp_ses );
-                                obj.data.previous_menu_perms = obj.data.menu_perms;
+                                if (obj.data.session.is_perm === false) {
+                                    obj.data.list.au[1] = JSON2js( temp_au );
+                                    obj.data.stash('list');
+                                    obj.data.previous_session = JSON2js( temp_ses );
+                                    obj.data.previous_menu_perms = obj.data.menu_perms;
+                                    obj.data.stash('previous_session');
+                                    obj.data.stash('previous_menu_perms');
+                                } else {
+                                    var temp_session_object = JSON2js( temp_ses );
+                                    network.simple_request('AUTH_DELETE', [ temp_session_object.key ] );
+                                }
                                 obj.data.menu_perms = false;
-                                obj.data.stash('previous_session');
-                                obj.data.stash('previous_menu_perms');
                                 obj.data.stash('menu_perms');
                             }
                         }
index e2f4ed9..664366c 100644 (file)
@@ -94,7 +94,8 @@
                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
                 XML_HTTP_SERVER = g.data.server_unadorned;
 
-                document.title = g.window.appshell_name_increment() + ': ' + g.data.list.au[0].usrname() + '@' + g.data.ws_name + '.' + g.data.server_unadorned;
+                window.egwinid = g.window.appshell_name_increment();
+                document.title = window.egwinid + ': ' + g.data.list.au[0].usrname() + '@' + g.data.ws_name + '.' + g.data.server_unadorned;
 
                 var delay = g.data.hash.aous["ui.general.idle_timeout"];
                 if (delay) setup_idle_observer(delay);
index e999028..395e50d 100644 (file)
@@ -296,17 +296,15 @@ util.network.prototype = {
             JSAN.use('util.window'); var win =  new util.window();
             var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
             var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
-            var enumerator = windowManagerInterface.getEnumerator(null);
+            var enumerator = windowManagerInterface.getEnumerator('eg_menu');
 
             var w; // set title on all appshell windows
             while ( w = enumerator.getNext() ) {
-                if (w.document.title.match(/^\d/)) {
-                    w.document.title = 
-                        win.appshell_name_increment() 
-                        + ': ' + data.list.au[0].usrname() 
-                        + '@' + data.ws_name;
-                        + '.' + data.server_unadorned 
-                }
+                w.document.title = 
+                    w.egwinid
+                    + ': ' + data.list.au[0].usrname() 
+                    + '@' + data.ws_name
+                    + '.' + data.server_unadorned; 
             }
         } catch(E) {
             obj.error.standard_unexpected_error_alert(offlineStrings.getString('network.window_title.error'),E);
@@ -350,6 +348,8 @@ util.network.prototype = {
         var url = urls.XUL_AUTH_SIMPLE;
         if (typeof xulG != 'undefined' && typeof xulG.url_prefix == 'function') url = xulG.url_prefix( url );
         JSAN.use('util.window'); var win = new util.window();
+        JSAN.use('OpenILS.data');
+        var data = new OpenILS.data(); data.init({'via':'stash'});
         var my_xulG = win.open(
             url,
             //+ '?login_type=staff'
@@ -359,17 +359,18 @@ util.network.prototype = {
             offlineStrings.getString('network.new_session.authorize'),
             'chrome,resizable,modal,width=700,height=500',
             {
-                'login_type' : 'staff',
+                'login_type' : text ? (data.session.login_type ? data.session.login_type : 'staff') : 'ochange',
                 'desc_brief' : text ? offlineStrings.getString('network.new_session.expired') : offlineStrings.getString('network.new_session.operator_change'),
                 'desc_full' : text ? offlineStrings.getString('network.new_session.expired.prompt') : offlineStrings.getString('network.new_session.operator_change.prompt')
                 //'simple_auth' : (new Date()).toString(),
             }
         );
-        JSAN.use('OpenILS.data');
-        var data = new OpenILS.data(); data.init({'via':'stash'});
+        data.stash_retrieve();
         if (typeof data.temporary_session != 'undefined' && data.temporary_session != '') {
             data.session.key = data.temporary_session.key; 
             data.session.authtime = data.temporary_session.authtime; 
+            data.session.is_perm = data.temporary_session.is_perm; // For operator change, otherwise ignorable.
+            data.session.login_type = data.temporary_session.login_type; // For timeouts *after* operator change.
             data.stash('session');
             try {
                 var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
index e311333..7e7a7d3 100644 (file)
@@ -37,6 +37,7 @@
     <![CDATA[
 
         var offlineStrings = document.getElementById('offlineStrings');
+        var login_type = 'temp';
 
         function my_init() {
             try {
 
                 $('server').value = g.data.server_unadorned;
 
-                addCSSClass(document.documentElement,xul_param('login_type'))
+                login_type = xul_param('login_type') || 'temp';
+                addCSSClass(document.documentElement,login_type)
+                if(login_type == 'ochange')
+                    $('change_type_row').hidden = false;
 
                 if (xul_param('desc_brief')) {
                     $('desc').hidden = false;
 
         function authorize() {
             try {
+                var my_login_type = login_type;
+                var is_perm = false;
+                if(login_type == 'ochange') {
+                    my_login_type = $('change_type').value;
+                    if(my_login_type == 'perm') {
+                        my_login_type = 'staff';
+                        is_perm = true;
+                    }
+                }
                 JSAN.use('auth.session');
                 g.session = new auth.session(
                     {
                         'password_prompt' : $('password'),
                         'server_prompt' : $('server'),
                     },
-                    xul_param('login_type') || 'temp'
+                    my_login_type
                 );
                 g.session.on_init = function() { 
                     try {
                         g.data.temporary_session = {  // old way because of local chrome still out there
                             'key' : g.session.key, 
                             'authtime' : g.session.authtime, 
-                            'usr' : js2JSON(staff)
+                            'usr' : js2JSON(staff),
+                            'is_perm' : is_perm,
+                            'login_type' : my_login_type
                         }
                         g.data.stash('temporary_session');
                         xulG.temporary_session = g.data.temporary_session;
     <groupbox>
         <caption label="&staff.main.simple_auth.authorization.label;"/>
         <grid>
-            <columns><column /><column /></columns>
+            <columns><column /><column /><column flex="1" /></columns>
             <rows>
                 <row>
                     <label value="&common.username.label;" control="username" accesskey="&common.username.accesskey;"/>
                     <label value="&staff.auth.password_prompt;" control="password" accesskey="&staff.auth.password_prompt.accesskey;"/>
                     <textbox id="password" type="password"/>
                 </row>
+                <row id="change_type_row" hidden="true">
+                    <label value="&staff.auth.change_type.label;" control="change_type" accesskey="&staff.auth.change_type.accesskey;"/>
+                    <menulist id="change_type">
+                        <menupopup>
+                                <menuitem label="&staff.auth.change_type_temporary;" value="temp" selected="true"/>
+                                <menuitem label="&staff.auth.change_type_staff;" value="staff"/>
+                                <menuitem label="&staff.auth.change_type_permanent;" value="perm"/>
+                        </menupopup>
+                    </menulist>
+                    <description>&staff.auth.change_type_description;</description>
+                </row>
                 <row>
                     <button label="&common.cancel;" accesskey="&common.cancel.accesskey;" oncommand="window.close()"/>
                     <button label="&staff.main.simple_auth.authorize.label;" accesskey="&staff.main.simple_auth.authorize.accesskey;" oncommand="authorize()"/>