r8629: - moved the getDomainList() call out of smbcalls_auth.c and into libjs/auth.js
[kai/samba.git] / swat / login.esp
1 <% page_header("plain", "SWAT Login", "");
2    libinclude("auth.js");
3
4 if (request['SESSION_EXPIRED'] == "True") {
5    write("<b>Your session has expired - please authenticate again<br /></b>\n");
6 }
7
8 var f = FormObj("login", 3, 1);
9 f.element[0].label = "Username";
10 f.element[0].value = form['Username'];
11 f.element[1].label = "Password";
12 f.element[1].value = form['Password'];
13 f.element[1].type  = "password";
14 f.element[2].label = "Domain";
15 f.element[2].type  = "select";
16 f.element[2].list  = getDomainList();
17 f.submit[0] = "Login";
18
19 display_form(f);
20 %>
21
22 <%
23         if (request.REQUEST_METHOD == "POST") {
24
25                 var authinfo = new Object();
26                 authinfo.username = form.Username;
27                 authinfo.password = form.Password;
28                 authinfo.domain = form.Domain;
29                 authinfo.rhost = request['REMOTE_HOST'];
30
31                 auth = userAuth(authinfo);
32                 if (auth.result) {
33
34                         /* for now just authenticate everyone */
35                         session.AUTHENTICATED = true;
36                         session.authinfo = new Object();
37
38                         session.authinfo.username = auth.username;
39                         session.authinfo.domain = auth.domain;
40
41                         /* if the user was asking for the login page, then now
42                            redirect them to the main page. Otherwise just
43                            redirect them to the current page, which will now
44                            show its true content */
45                         if (request.REQUEST_URI == "/login.esp") {
46                            redirect(session_uri("/"));
47                         } else {
48                            redirect(session_uri(request.REQUEST_URI));
49                         }
50                 } else {
51                         write("<b>Login failed - please try again<br /></b>\n");
52                 }
53         }
54 %>
55 <% page_footer(); %>