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