r12945: Try to move closer to getting Samba3 import working again.
[jelmer/samba4-debian.git] / swat / login.esp
index 257567d267186b1af75e51f7b2b921f2579871df..8d6c049d02d80b6eb4c6f7483ead1e4e2502b8a3 100644 (file)
@@ -1,5 +1,6 @@
 <% page_header("plain", "SWAT Login", "");
    libinclude("auth.js");
+   include("/scripting/forms.js");
 
 if (request['SESSION_EXPIRED'] == "True") {
    write("<b>Your session has expired - please authenticate again<br /></b>\n");
@@ -16,28 +17,29 @@ f.element[2].type  = "select";
 f.element[2].list  = getDomainList();
 f.submit[0] = "Login";
 
-display_form(f);
+f.display();
 %>
 
 <%
        if (request.REQUEST_METHOD == "POST") {
-
-               var authinfo = new Object();
-               authinfo.username = form.Username;
-               authinfo.password = form.Password;
-               authinfo.domain = form.Domain;
-               authinfo.rhost = request['REMOTE_HOST'];
-
-               auth = userAuth(authinfo);
-               if (auth.result) {
-
-                       /* for now just authenticate everyone */
+               var creds = credentials_init();
+               creds.set_username(form.Username);
+               creds.set_password(form.Password);
+               creds.set_domain(form.Domain);
+               creds.set_workstation(request['REMOTE_HOST']);
+
+               auth = userAuth(creds, request['REMOTE_SOCKET_ADDRESS']);
+               if (auth == undefined) {
+                       write("<b>Invalid login - please try again<br /></b>\n");
+               } else if (auth.result) {
                        session.AUTHENTICATED = true;
                        session.authinfo = new Object();
 
                        session.authinfo.username = auth.username;
                        session.authinfo.domain = auth.domain;
-
+                       session.authinfo.credentials = creds;
+                       session.authinfo.session_info = auth.session_info;
+                       
                        /* if the user was asking for the login page, then now
                           redirect them to the main page. Otherwise just
                           redirect them to the current page, which will now
@@ -47,8 +49,10 @@ display_form(f);
                        } else {
                           redirect(session_uri(request.REQUEST_URI));
                        }
-               } else {
+               } else if (auth.report == undefined) {
                        write("<b>Login failed - please try again<br /></b>\n");
+               } else {
+                       write("<b>Login failed: " + auth.report + " - please try again<br /></b>\n");
                }
        }
 %>