r7238: Add pam auth support in swat
[sfrench/samba-autobuild/.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                 auth = userAuth(form.Username, form.Password, form.Domain);
27                 if (auth.result) {
28
29                         /* for now just authenticate everyone */
30                         session.AUTHENTICATED = true;
31                         session.authinfo = new Object();
32
33                         session.authinfo.username = auth.username;
34                         session.authinfo.domain = auth.domain;
35
36                         /* if the user was asking for the login page, then now
37                            redirect them to the main page. Otherwise just
38                            redirect them to the current page, which will now
39                            show its true content */
40                         if (request.REQUEST_URI == "/login.esp") {
41                            redirect(session_uri("/"));
42                         } else {
43                            redirect(session_uri(request.REQUEST_URI));
44                         }
45                 } else {
46                         write("<b>Login failed - please try again<br /></b>\n");
47                 }
48         }
49 %>
50 <% page_footer(); %>