]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/passwordauth.pm
passwordauth: prevent authentication bypass via multiple name parameters
[git.ikiwiki.info.git] / IkiWiki / Plugin / passwordauth.pm
index fb3fd9ee1620911558ec09c96b466405a3a0592a..0dde0386e7efce0e10624fb8b8b33e6e14f3e032 100644 (file)
@@ -325,12 +325,13 @@ sub formbuilder (@) {
 
        if ($form->title eq "signin" || $form->title eq "register") {
                if (($form->submitted && $form->validate) || $do_register) {
+                       my $user_name = $form->field('name');
+
                        if ($form->submitted eq 'Login') {
-                               $session->param("name", $form->field("name"));
+                               $session->param("name", $user_name);
                                IkiWiki::cgi_postsignin($cgi, $session);
                        }
                        elsif ($form->submitted eq 'Create Account') {
-                               my $user_name=$form->field('name');
                                if (IkiWiki::userinfo_setall($user_name, {
                                        'email' => $form->field('email'),
                                        'regdate' => time})) {
@@ -344,7 +345,6 @@ sub formbuilder (@) {
                                }
                        }
                        elsif ($form->submitted eq 'Reset Password') {
-                               my $user_name=$form->field("name");
                                my $email=IkiWiki::userinfo_get($user_name, "email");
                                if (! length $email) {
                                        error(gettext("No email address, so cannot email password reset instructions."));