summaryrefslogtreecommitdiff
path: root/swat
diff options
context:
space:
mode:
Diffstat (limited to 'swat')
-rw-r--r--swat/install/provision.esp41
-rw-r--r--swat/scripting/forms.js19
2 files changed, 38 insertions, 22 deletions
diff --git a/swat/install/provision.esp b/swat/install/provision.esp
index 9316445d7f..284be96a5f 100644
--- a/swat/install/provision.esp
+++ b/swat/install/provision.esp
@@ -8,7 +8,7 @@
<h1>Samba4 provisioning</h1>
<%
-var f = FormObj("Provisioning", 9, 2);
+var f = FormObj("Provisioning", 0, 3);
var i;
var lp = loadparm_init();
@@ -18,26 +18,19 @@ if (lp.get("realm") == "") {
var subobj = provision_guess();
+/* Don't supply default password for web interface */
+subobj.ADMINPASS = "";
-f.element[0].label = "Realm";
-f.element[0].name = "REALM";
-f.element[1].label = "Domain Name";
-f.element[1].name = "DOMAIN";
-f.element[2].label = "Host Name";
-f.element[2].name = "HOSTNAME";
-f.element[3].label = "Administrator Password";
-f.element[3].name = "ADMINPASS";
-f.element[3].type = "password";
-f.element[4].label = "Domain SID";
-f.element[4].name = "DOMAINSID";
-f.element[5].label = "Host GUID";
-f.element[5].name = "HOSTGUID";
-f.element[6].label = "Base DN";
-f.element[6].name = "BASEDN";
-f.element[7].label = "Host IP";
-f.element[7].name = "HOSTIP";
-f.element[8].label = "Default Site";
-f.element[8].name = "DEFAULTSITE";
+f.add("REALM", "Realm");
+f.add("DOMAIN", "Domain Name");
+f.add("HOSTNAME", "Hostname");
+f.add("ADMINPASS", "Administrator Password", "password");
+f.add("CONFIRM", "Confirm Password", "password");
+f.add("DOMAINSID", "Domain SID");
+f.add("HOSTGUID", "Host GUID");
+f.add("BASEDN", "Base DN");
+f.add("HOSTIP", "Host IP");
+f.add("DEFAULTSITE", "Default Site");
f.submit[0] = "Initial provision";
f.submit[1] = "Provision";
f.submit[2] = "Cancel";
@@ -58,11 +51,15 @@ for (i=0;i<f.element.length;i++) {
lp.set("realm", subobj.REALM);
-if (form['submit'] == "Provision") {
+var goodpass = (subobj.CONFIRM == subobj.ADMINPASS);
+if (form['submit'] == "Provision" && goodpass) {
provision(subobj, writefln, true);
-} else if (form['submit'] == "Initial provision") {
+} else if (form['submit'] == "Initial provision" && goodpass) {
provision(subobj, writefln, false);
} else {
+ if (!goodpass && form['submit'] != undefined) {
+ write("<h3>Passwords don't match. Please try again.</h3>");
+ }
f.display();
}
%>
diff --git a/swat/scripting/forms.js b/swat/scripting/forms.js
index e44deeb180..2de9e34462 100644
--- a/swat/scripting/forms.js
+++ b/swat/scripting/forms.js
@@ -10,6 +10,8 @@
f.action = action to be taken on submit (optional, defaults to current page)
f.class = css class (optional, defaults to 'form')
f.submit = an array of submit labels
+ f.add(name, label, [type], [value]) =
+ Add another element
f.element[i].label = element label
f.element[i].name = element name (defaults to label)
f.element[i].type = element type (defaults to text)
@@ -69,6 +71,22 @@ function form_display() {
write("</form>\n");
}
+function __addMethod(name, label)
+{
+ var f = this;
+ var i = f.element.length;
+ f.element[i] = new Object();
+ f.element[i].name = name;
+ f.element[i].label = label;
+ f.element[i].type = "text";
+ f.element[i].value = "";
+ if (arguments.length > 2) {
+ f.element[i].type = arguments[2];
+ }
+ if (arguments.length > 3) {
+ f.element[i].value = arguments[3];
+ }
+}
/*
create a Form object with the defaults filled in, ready for display()
@@ -81,6 +99,7 @@ function FormObj(name, num_elements, num_submits)
f.submit = new Array(num_submits);
f.action = session_uri(request.REQUEST_URI);
f.class = "defaultform";
+ f.add = __addMethod;
for (i in f.element) {
f.element[i] = new Object();
f.element[i].type = "text";