X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/ee1ad53c4c2710aa7ded61bdc56f3a8cce514f22..b9dc3e84a512eecf66b2b3e73be39530b588f49c:/IkiWiki/Plugin/passwordauth.pm diff --git a/IkiWiki/Plugin/passwordauth.pm b/IkiWiki/Plugin/passwordauth.pm index 131b3a43e..1520cea83 100644 --- a/IkiWiki/Plugin/passwordauth.pm +++ b/IkiWiki/Plugin/passwordauth.pm @@ -21,11 +21,12 @@ 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(""); @@ -51,6 +52,13 @@ sub formbuilder_setup (@) { #{{{ shift eq $form->field("password"); }, ); + $form->field( + name => "account_creation_password", + validate => sub { + shift eq $config{account_creation_password}; + }, + required => 1, + ) if (length $config{account_creation_password}); $form->field( name => "email", validate => "EMAIL", @@ -101,17 +109,20 @@ sub formbuilder_setup (@) { #{{{ } else { # First time settings. - $form->field(name => "name", comment => gettext("(use FirstnameLastName)")); + $form->field(name => "name"); if ($session->param("name")) { $form->field(name => "name", value => $session->param("name")); } } } elsif ($form->title eq "preferences") { - $form->field(name => "name", disabled => 1, value => - $session->param("name"), force => 1); - $form->field(name => "password", type => "password"); + $form->field(name => "name", disabled => 1, + value => $session->param("name"), force => 1, + fieldset => "login"); + $form->field(name => "password", type => "password", + fieldset => "login"); $form->field(name => "confirm_password", type => "password", + fieldset => "login", validate => sub { shift eq $form->field("password"); }); @@ -186,7 +197,7 @@ sub formbuilder (@) { #{{{ if ($form->submitted eq "Save Preferences" && $form->validate) { my $user_name=$form->field('name'); foreach my $field (qw(password)) { - if (defined $form->field($field) && length $form->field($field)) { + if (defined $form->field($field)) { IkiWiki::userinfo_set($user_name, $field, $form->field($field)) || error("failed to set $field"); }