]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/main/simple_auth.xul
auth dialogs
[working/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(); } 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                                         g.data.temporary_session = { 'key' : g.session.key, 'authtime' : g.session.authtime };
98                                         g.data.stash('temporary_session');
99                                         window.close();
100                                 }
101                                 g.session.on_init_error = function() { 
102                                         $('password').value = '';
103                                         $('username').focus();
104                                         $('username').select();
105                                  }
106                                 g.session.init();
107                         } catch(E) {
108                                 alert(E);
109                         }
110                 }
111
112         ]]>
113         </script>
114
115         <commandset id="simple_auth_cmds">
116                 <command id="cmd_broken" />
117         </commandset>
118
119         <vbox id="simple_auth_main" flex="1">
120         <groupbox id="desc" hidden="true">
121                 <caption label="Exception"/>
122                 <description id="desc_brief" style="color: red"/>
123                 <description id="desc_full"/>
124         </groupbox>
125         <groupbox>
126                 <caption label="Authorization"/>
127                 <grid>
128                         <columns><column /><column /></columns>
129                         <rows>
130                                 <row>
131                                         <label value="Username:" control="username" accesskey="U"/>
132                                         <textbox id="username" />
133                                 </row>
134                                 <row>
135                                         <label value="Password:" control="password" accesskey="P"/>
136                                         <textbox id="password" type="password"/>
137                                 </row>
138                                 <row>
139                                         <button label="Cancel" accesskey="C" oncommand="window.close()"/>
140                                         <button label="Authorize" accesskey="A" oncommand="authorize()"/>
141                                 </row>
142                         </rows>
143                 </grid>
144                 <label id="server" hidden="true"/>
145         </groupbox>
146         <spacer flex="1"/>
147         </vbox>
148 </window>
149