]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/passwordauth.pm
* Only try postsignin if no other action matched. Fixes a bug where the
[git.ikiwiki.info.git] / IkiWiki / Plugin / passwordauth.pm
index d1a965dc889c144f62a01bcba826ae192ec37b10..af16c27542257de13251adae31acdd6578d31b95 100644 (file)
@@ -21,14 +21,26 @@ sub formbuilder_setup (@) { #{{{
        my $cgi=$params{cgi};
 
        if ($form->title eq "signin" || $form->title eq "register") {
-               $form->field(name => "name", required => 0, size => 50);
+               $form->field(name => "name", required => 0);
                $form->field(name => "password", type => "password", required => 0);
                
                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",
@@ -101,7 +114,7 @@ sub formbuilder_setup (@) { #{{{
                }
                else {
                        # First time settings.
-                       $form->field(name => "name", size => 30);
+                       $form->field(name => "name");
                        if ($session->param("name")) {
                                $form->field(name => "name", value => $session->param("name"));
                        }
@@ -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");
-                       });
-               
+                       }),
        }
 }
 
@@ -196,9 +211,6 @@ sub formbuilder (@) { #{{{
                        }
                }
        }
-       
-       IkiWiki::printheader($session);
-       print IkiWiki::misctemplate($form->title, $form->render(submit => $buttons));
 } #}}}
 
 1