]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/passwordauth.pm
* Apply a patch from Carl Worth allowing a class attribute to be passed
[ikiwiki.git] / IkiWiki / Plugin / passwordauth.pm
index 86a5ba49e964fd6456a4249e0b82ae4dff9e6c0d..b61e6c86e1b118c5baeb852de95a187dc39de854 100644 (file)
@@ -26,9 +26,21 @@ sub formbuilder_setup (@) { #{{{
                
                if ($form->submitted eq "Register" || $form->submitted eq "Create Account") {
                        $form->field(name => "confirm_password", type => "password");
+                       $form->field(name => "account_creation_password", type => "password") if (length $config{account_creation_password});
                        $form->field(name => "email", size => 50);
                        $form->title("register");
                        $form->text("");
+               
+                       $form->field(name => "confirm_password",
+                               validate => sub {
+                                       shift eq $form->field("password");
+                               },
+                       );
+                       $form->field(name => "password",
+                               validate => sub {
+                                       shift eq $form->field("confirm_password");
+                               },
+                       );
                }
 
                if ($form->submitted) {
@@ -46,11 +58,12 @@ sub formbuilder_setup (@) { #{{{
        
                        if ($submittype eq "Create Account") {
                                $form->field(
-                                       name => "confirm_password",
+                                       name => "account_creation_password",
                                        validate => sub {
-                                               shift eq $form->field("password");
+                                               shift eq $config{account_creation_password};
                                        },
-                               );
+                                       required => 1,
+                               ) if (length $config{account_creation_password});
                                $form->field(
                                        name => "email",
                                        validate => "EMAIL",
@@ -112,13 +125,15 @@ sub formbuilder_setup (@) { #{{{
                        value => $session->param("name"), force => 1,
                        fieldset => "login");
                $form->field(name => "password", type => "password",
-                       fieldset => "login");
+                       fieldset => "login",
+                       validate => sub {
+                               shift eq $form->field("confirm_password");
+                       }),
                $form->field(name => "confirm_password", type => "password",
                        fieldset => "login",
                        validate => sub {
                                shift eq $form->field("password");
-                       });
-               
+                       }),
        }
 }