simple auth was buggy; due to chrome/remote restrictions in xulrunner 1.9? made separ...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Sep 2009 02:48:41 +0000 (02:48 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Sep 2009 02:48:41 +0000 (02:48 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14018 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/Makefile.am
Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_chrome.xul
Open-ILS/xul/staff_client/chrome/content/main/simple_auth.xul
Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul
Open-ILS/xul/staff_client/server/main/simple_auth.xul [new file with mode: 0644]

index fe1aac9..d04b644 100644 (file)
@@ -26,7 +26,6 @@ build_dir:
        @cp -fR build/chrome/content/util/ build/server/
        @cp -fR build/chrome/content/auth/ build/server/
        @cp build/chrome/content/main/constants.js build/server/main/constants.js
-       @cp build/chrome/content/main/simple_auth.xul build/server/main/simple_auth.xul
        @cp build/chrome/content/main/bindings.xml build/server/main/bindings.xml
        @cp build/chrome/content/OpenILS/data.js build/server/OpenILS/data.js
        @cp build/chrome/content/OpenILS/global_util.js build/server/OpenILS/global_util.js
@@ -34,7 +33,6 @@ build_dir:
 
 # Convert chrome to remote for server localization
 chrome2remote:
-       @sed -i 's/chrome:\/\/open_ils_staff_client\/locale\//\/xul\/server\/locale\/<\!--#echo var=locale-->\//' build/server/main/simple_auth.xul
        @for loc in $(CHROME_LOCALES); do \
                cp -fr chrome/locale/$$loc build/server/locale/. ; \
        done;
index cc4e031..9995ad3 100644 (file)
@@ -16,6 +16,7 @@
                <script type="text/javascript" src="util/org_utils.js" />   
                <script type="text/javascript" src="global_util.js" />   
                <messagecatalog id="offlineStrings" src='chrome://open_ils_staff_client/locale/offline.properties'/>
+               <messagecatalog id="authStrings" src='chrome://open_ils_staff_client/locale/auth.properties'/>
                <script>dump('finished openils_util_overlay\n');</script>
        </scripts>
 
index 3e58946..0157eed 100644 (file)
@@ -8,18 +8,16 @@
 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
 <!-- STYLESHEETS -->
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
-<?xml-stylesheet href="/xul/server/skin/simple_auth.css" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/auth.css" type="text/css"?>
 
 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
 <!-- LOCALIZATION -->
-<!DOCTYPE window PUBLIC "" ""[
-       <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
-]>
+<!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
 
 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
 <!-- OVERLAYS -->
-<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+<?xul-overlay href="chrome://open_ils_staff_client/OpenILS/content/util_overlay_chrome.xul"?>
 
 <window id="simple_auth_win" 
        onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
@@ -32,7 +30,6 @@
        </script>
         <scripts id="openils_util_scripts"/>
 
-       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
        <script>
        <![CDATA[
                function my_init() {
@@ -42,7 +39,7 @@
                                        throw( offlineStrings.getString('common.jsan.missing'));
                                }
                                JSAN.errorLevel = "die"; // none, warn, or die
-                               JSAN.addRepository('/xul/server/');
+                               JSAN.addRepository('..');
                                JSAN.use('util.error'); g.error = new util.error();
                                g.error.sdump('D_TRACE','my_init() for simple_auth.xul');
 
index ef47b07..4ed3075 100644 (file)
@@ -28,6 +28,7 @@
         </menupopup>
                <messagecatalog id="commonStrings" src='/xul/server/locale/<!--#echo var="locale"-->/common.properties'/>
                <messagecatalog id="offlineStrings" src='/xul/server/locale/<!--#echo var="locale"-->/offline.properties'/>
+               <messagecatalog id="authStrings" src='/xul/server/locale/<!--#echo var="locale"-->/auth.properties'/>
                <script>dump('finished openils_util_overlay\n');</script>
        </scripts>
 
diff --git a/Open-ILS/xul/staff_client/server/main/simple_auth.xul b/Open-ILS/xul/staff_client/server/main/simple_auth.xul
new file mode 100644 (file)
index 0000000..e89f6dc
--- /dev/null
@@ -0,0 +1,169 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Example Template for remote xul -->
+<!--
+ vim:noet:sw=4:ts=4:
+-->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/simple_auth.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+       <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="simple_auth_win" 
+       onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+       <!-- BEHAVIOR -->
+        <script type="text/javascript">
+               var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
+       </script>
+        <scripts id="openils_util_scripts"/>
+
+       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+       <script>
+       <![CDATA[
+
+        var offlineStrings = document.getElementById('offlineStrings');
+
+               function my_init() {
+                       try {
+                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                               if (typeof JSAN == 'undefined') { 
+                                       throw( offlineStrings.getString('common.jsan.missing'));
+                               }
+                               JSAN.errorLevel = "die"; // none, warn, or die
+                               JSAN.addRepository('/xul/server/');
+                               JSAN.use('util.error'); g.error = new util.error();
+                               g.error.sdump('D_TRACE','my_init() for simple_auth.xul');
+
+                               JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+                               g.data.temporary_session = ''; g.data.stash('temporary_session');
+
+                               $('server').value = g.data.server_unadorned;
+
+                               addCSSClass(document.documentElement,xul_param('login_type',{'modal_xulG':true}))
+
+                               if (xul_param('desc_brief',{'modal_xulG':true})) {
+                                       $('desc').hidden = false;
+                                       $('desc_brief').appendChild( document.createTextNode( xul_param('desc_brief',{'modal_xulG':true}) ) );
+                               }
+                               if (xul_param('desc_full',{'modal_xulG':true})) {
+                                       $('desc').hidden = false;
+                                       $('desc_full').appendChild( document.createTextNode( xul_param('desc_full',{'modal_xulG':true}) ) );
+                               }
+
+                               $('username').focus();
+
+                               $('username').addEventListener('keypress',handle_keypress,false);
+                               $('password').addEventListener('keypress',handle_keypress,false);
+
+                       } catch(E) {
+                               var err_msg =  offlineStrings.getFormattedString('common.exception', ['simple_auth.xul', E]);
+                               try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+                               alert(err_msg);
+                       }
+               }
+
+               function $(id) { return document.getElementById(id); }
+
+               function handle_keypress(ev) {
+                       if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
+                       switch(ev.target) {
+                               case $('username') : $('password').focus(); break;
+                               case $('password') : authorize(); break;
+                               default: break;
+                       }
+               }
+
+               function authorize() {
+                       try {
+                               JSAN.use('auth.session');
+                               g.session = new auth.session(
+                                       {
+                                               'name_prompt' : $('username'),
+                                               'password_prompt' : $('password'),
+                                               'server_prompt' : $('server'),
+                                       },
+                                       xul_param('login_type',{'modal_xulG':true}) || 'temp'
+                               );
+                               g.session.on_init = function() { 
+                                       try {
+                                               JSAN.use('util.network'); var n = new util.network();
+                                               var staff = n.simple_request('FM_AU_RETRIEVE_VIA_SESSION',[ g.session.key ]);
+                                               g.data.temporary_session = {  // old way because of local chrome still out there
+                                                       'key' : g.session.key, 
+                                                       'authtime' : g.session.authtime, 
+                                                       'usr' : js2JSON(staff)
+                                               }
+                                               g.data.stash('temporary_session');
+                                               var my_xulG = { // new way, to minimize the use of global spaces
+                                                       'temporary_session' : g.data.temporary_session
+                                               };
+                                               update_modal_xulG(my_xulG);
+                                               window.close();
+                                       } catch(E) {
+                                               g.error.standard_unexpected_error_alert('simple_auth.session.on_init',E);
+                                       }
+                               }
+                               g.session.on_init_error = function() { 
+                                       $('password').value = '';
+                                       $('username').focus();
+                                       $('username').select();
+                                }
+                               g.session.init();
+                       } catch(E) {
+                               alert(E);
+                       }
+               }
+
+       ]]>
+       </script>
+
+       <commandset id="simple_auth_cmds">
+               <command id="cmd_broken" />
+       </commandset>
+
+       <vbox id="simple_auth_main" flex="1">
+       <groupbox id="desc" hidden="true">
+               <caption label="&staff.main.simple_auth.exception.label;"/>
+               <description id="desc_brief" style="color: red"/>
+               <description id="desc_full"/>
+       </groupbox>
+       <groupbox>
+               <caption label="&staff.main.simple_auth.authorization.label;"/>
+               <grid>
+                       <columns><column /><column /></columns>
+                       <rows>
+                               <row>
+                                       <label value="&common.username.label;" control="username" accesskey="&common.username.accesskey;"/>
+                                       <textbox id="username" />
+                               </row>
+                               <row>
+                                       <label value="&staff.auth.password_prompt;" control="password" accesskey="&staff.auth.password_prompt.accesskey;"/>
+                                       <textbox id="password" type="password"/>
+                               </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()"/>
+                               </row>
+                       </rows>
+               </grid>
+               <label id="server" hidden="true"/>
+       </groupbox>
+       <spacer flex="1"/>
+       </vbox>
+</window>
+