X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/d4c61b72813b880d86b316770f2e3819a6428202..459737780bcec043b530ccc74897c3e60dc2d967:/IkiWiki/Plugin/passwordauth.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/passwordauth.pm b/IkiWiki/Plugin/passwordauth.pm index e0aa72a19..b61e6c86e 100644 --- a/IkiWiki/Plugin/passwordauth.pm +++ b/IkiWiki/Plugin/passwordauth.pm @@ -4,7 +4,7 @@ package IkiWiki::Plugin::passwordauth; use warnings; use strict; -use IkiWiki; +use IkiWiki 2.00; sub import { #{{{ hook(type => "formbuilder_setup", id => "passwordauth", @@ -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,21 +114,26 @@ 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", + validate => sub { + shift eq $form->field("confirm_password"); + }), $form->field(name => "confirm_password", type => "password", + fieldset => "login", validate => sub { shift eq $form->field("password"); - }); - + }), } }