r8708: fixed an assert that abartlet found
[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 == undefined) {
33                         write("<b>Invalid login - please try again<br /></b>\n");
34                 } else if (auth.result) {
35
36                         /* for now just authenticate everyone */
37                         session.AUTHENTICATED = true;
38                         session.authinfo = new Object();
39
40                         session.authinfo.username = auth.username;
41                         session.authinfo.domain = auth.domain;
42
43                         /* if the user was asking for the login page, then now
44                            redirect them to the main page. Otherwise just
45                            redirect them to the current page, which will now
46                            show its true content */
47                         if (request.REQUEST_URI == "/login.esp") {
48                            redirect(session_uri("/"));
49                         } else {
50                            redirect(session_uri(request.REQUEST_URI));
51                         }
52                 } else {
53                         write("<b>Login failed - please try again<br /></b>\n");
54                 }
55         }
56 %>
57 <% page_footer(); %>