]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/main/simple_auth.xul
font resizer
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / main / simple_auth.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Example Template for remote xul -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/simple_auth.css" type="text/css"?>
10
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window PUBLIC "" ""[
14         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
15 ]>
16
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <!-- OVERLAYS -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20
21 <window id="simple_auth_win" 
22         onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
23         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
24
25         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
26         <!-- BEHAVIOR -->
27         <script type="text/javascript">
28                 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
29         </script>
30         <scripts id="openils_util_scripts"/>
31
32         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
33         <script>
34         <![CDATA[
35                 function my_init() {
36                         try {
37                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
38                                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
39                                 JSAN.errorLevel = "die"; // none, warn, or die
40                                 JSAN.addRepository('/xul/server/');
41                                 JSAN.use('util.error'); g.error = new util.error();
42                                 g.error.sdump('D_TRACE','my_init() for simple_auth.xul');
43
44                                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
45                                 g.data.temporary_session = ''; g.data.stash('temporary_session');
46
47                                 $('server').value = g.data.server_unadorned;
48
49                                 g.cgi = new CGI();
50                                 addCSSClass(document.documentElement,g.cgi.param('login_type'))
51
52                                 if (g.cgi.param('desc_brief')) {
53                                         $('desc').hidden = false;
54                                         $('desc_brief').appendChild( document.createTextNode( g.cgi.param('desc_brief') ) );
55                                 }
56                                 if (g.cgi.param('desc_full')) {
57                                         $('desc').hidden = false;
58                                         $('desc_full').appendChild( document.createTextNode( g.cgi.param('desc_full') ) );
59                                 }
60
61                                 $('username').focus();
62
63                                 $('username').addEventListener('keypress',handle_keypress,false);
64                                 $('password').addEventListener('keypress',handle_keypress,false);
65
66                         } catch(E) {
67                                 var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
68                                         "system administrator or software developer the following:\nquick_auth.xul\n" + E + '\n';
69                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
70                                 alert(err_msg);
71                         }
72                 }
73
74                 function $(id) { return document.getElementById(id); }
75
76                 function handle_keypress(ev) {
77                         if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
78                         switch(ev.target) {
79                                 case $('username') : $('password').focus(); break;
80                                 case $('password') : authorize(); break;
81                                 default: break;
82                         }
83                 }
84
85                 function authorize() {
86                         try {
87                                 JSAN.use('auth.session');
88                                 g.session = new auth.session(
89                                         {
90                                                 'name_prompt' : $('username'),
91                                                 'password_prompt' : $('password'),
92                                                 'server_prompt' : $('server'),
93                                         },
94                                         g.cgi.param('login_type') || 'temp'
95                                 );
96                                 g.session.on_init = function() { 
97                                         JSAN.use('util.network'); var n = new util.network();
98                                         var staff = n.simple_request('FM_AU_RETRIEVE_VIA_SESSION',[ g.session.key ]);
99                                         g.data.temporary_session = { 'key' : g.session.key, 'authtime' : g.session.authtime, 'usr' : js2JSON(staff) };
100                                         g.data.stash('temporary_session');
101                                         window.close();
102                                 }
103                                 g.session.on_init_error = function() { 
104                                         $('password').value = '';
105                                         $('username').focus();
106                                         $('username').select();
107                                  }
108                                 g.session.init();
109                         } catch(E) {
110                                 alert(E);
111                         }
112                 }
113
114         ]]>
115         </script>
116
117         <commandset id="simple_auth_cmds">
118                 <command id="cmd_broken" />
119         </commandset>
120
121         <vbox id="simple_auth_main" flex="1">
122         <groupbox id="desc" hidden="true">
123                 <caption label="Exception"/>
124                 <description id="desc_brief" style="color: red"/>
125                 <description id="desc_full"/>
126         </groupbox>
127         <groupbox>
128                 <caption label="Authorization"/>
129                 <grid>
130                         <columns><column /><column /></columns>
131                         <rows>
132                                 <row>
133                                         <label value="Username:" control="username" accesskey="U"/>
134                                         <textbox id="username" />
135                                 </row>
136                                 <row>
137                                         <label value="Password:" control="password" accesskey="P"/>
138                                         <textbox id="password" type="password"/>
139                                 </row>
140                                 <row>
141                                         <button label="Cancel" accesskey="C" oncommand="window.close()"/>
142                                         <button label="Authorize" accesskey="A" oncommand="authorize()"/>
143                                 </row>
144                         </rows>
145                 </grid>
146                 <label id="server" hidden="true"/>
147         </groupbox>
148         <spacer flex="1"/>
149         </vbox>
150 </window>
151