small tweaks
[working/Evergreen.git] / Open-ILS / src / reporter / templates / login.ttk
1 <html>
2
3         [% INCLUDE header.ttk title="Login" %]
4
5         <body onload='initPage();'>
6
7                 <script language='javascript'>
8
9                         var COOKIE_SES = "ses";
10                         var cookie = new cookieObject("ses", 1, "/", COOKIE_SES);
11
12                         function initPage() {
13                         document.getElementById("reports_login_username").onkeypress = checkInputClicks;
14                         document.getElementById("reports_login_password").onkeypress = checkInputClicks;
15                         }
16
17                         function checkInputClicks(evt) {
18                                 if(userPressedEnter(evt)) doLogin();
19                         }
20
21
22                         function doLogin() {
23
24                         var uname = document.getElementById("reports_login_username").value;
25                         var passwd = document.getElementById("reports_login_password").value;
26                         
27                         var init_request = new RemoteRequest( 
28                                         "open-ils.auth", 
29                                         "open-ils.auth.authenticate.init", uname );
30         
31                         init_request.send(true);
32                         var seed = init_request.getResultObject();
33                         
34                         if( ! seed || seed == '0') {
35                         alert( "Error Communicating with Authentication Server" );
36                         return null;
37                         }
38                         
39                         var auth_request = new RemoteRequest( 
40                                         "open-ils.auth", "open-ils.auth.authenticate.complete",
41                         uname, hex_md5(seed + hex_md5(passwd)), "staff");
42                         
43                         auth_request.send(true);
44                         var auth_result = auth_request.getResultObject();
45                         
46                         if(auth_result == '0' || auth_result == null || auth_result.length == 0) { 
47                                         alert("Login failed");
48                                         return false; 
49                                 }
50         
51                                 cookie.put(COOKIE_SES, auth_result);
52                                 cookie.write();
53                                 location.href = location.href;
54                 
55                         }
56
57                 </script>
58
59                 <br/><br/>
60                 <h3> Reports Login </h3>
61                 <table style='padding: 4px; border: 2px solid #E0E0E0;'>
62                         <tr>
63                                 <td >Username: </td>
64                                 <td ><input type='text' id='reports_login_username'/></td>
65                         </tr>
66                         <tr>
67                                 <td >Password: </td>
68                                 <td ><input type='password' id='reports_login_password'/></td>
69                         <tr>
70                         </tr>
71                                 <td><input type='submit' value='Login' onclick='doLogin();'/></td>
72                         </tr>
73                 </table>
74         </body>
75
76         [% INCLUDE footer.ttk %]
77
78 </html>
79
80
81
82