X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/4c320176c080038f95131f39ecaca3101b4b1745..df5de5b967a1e6e14161fd1269efe5b17d33eec1:/IkiWiki/CGI.pm diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 49a505514..f2a32a958 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -22,7 +22,7 @@ sub printheader ($) { } } -sub showform ($$$$;@) { +sub prepform { my $form=shift; my $buttons=shift; my $session=shift; @@ -35,6 +35,16 @@ sub showform ($$$$;@) { }); } + return $form; +} + +sub showform ($$$$;@) { + my $form=prepform(@_); + shift; + my $buttons=shift; + my $session=shift; + my $cgi=shift; + printheader($session); print misctemplate($form->title, $form->render(submit => $buttons), @_); } @@ -90,9 +100,10 @@ sub needsignin ($$) { } } -sub cgi_signin ($$) { +sub cgi_signin ($$;$) { my $q=shift; my $session=shift; + my $returnhtml=shift; decode_cgi_utf8($q); eval q{use CGI::FormBuilder}; @@ -112,9 +123,6 @@ sub cgi_signin ($$) { ); my $buttons=["Login"]; - if ($q->param("do") ne "signin" && !$form->submitted) { - $form->text(gettext("You need to log in first.")); - } $form->field(name => "do", type => "hidden", value => "signin", force => 1); @@ -129,6 +137,11 @@ sub cgi_signin ($$) { $form->validate; } + if ($returnhtml) { + $form=prepform($form, $buttons, $session, $q); + return $form->render(submit => $buttons); + } + showform($form, $buttons, $session, $q); } @@ -234,7 +247,9 @@ sub cgi_prefs ($$) { $form->text(gettext("Preferences saved.")); } - showform($form, $buttons, $session, $q); + showform($form, $buttons, $session, $q, + prefsurl => "", # avoid showing the preferences link + ); } sub cgi_custom_failure ($$$) { @@ -268,7 +283,7 @@ sub check_banned ($$) { foreach my $b (@{$config{banned_users}}) { if (pagespec_match("", $b, - ip => $ENV{REMOTE_ADDR}, + ip => $session->remote_addr(), name => defined $name ? $name : "", )) { $banned=1;