-sub checkconfig () { #{{{
- # Currently part of the OpenID code is in CGI.pm, and is enabled by
- # this setting.
- # TODO: modularise it all out into this plugin..
- $config{openid}=1;
-} #}}}
-
-sub auth ($$) { #{{{
- my $q=shift;
- my $session=shift;
-
- if (defined $q->param('openid.mode')) {
- my $csr=getobj($q, $session);
-
- if (my $setup_url = $csr->user_setup_url) {
- IkiWiki::redirect($q, $setup_url);
- }
- elsif ($csr->user_cancel) {
- IkiWiki::redirect($q, $config{url});
- }
- elsif (my $vident = $csr->verified_identity) {
- $session->param(name => $vident->url);
- }
- else {
- error("OpenID failure: ".$csr->err);
+sub formbuilder_setup (@) { #{{{
+ my %params=@_;
+
+ my $form=$params{form};
+ my $session=$params{session};
+ my $cgi=$params{cgi};
+
+ if ($form->title eq "signin") {
+ $form->field(
+ name => "openid_url",
+ label => "OpenID",
+ size => 30,
+ comment => '('.
+ htmllink("", "", "OpenID", noimageinline => 1, linktext => gettext("What's this?"))
+ .($config{openidsignup} ? " | <a href=\"$config{openidsignup}\">".gettext("Get an OpenID")."</a>" : "")
+ .')'
+ );
+
+ # Handle submission of an OpenID as validation.
+ if ($form->submitted && $form->submitted eq "Login" &&
+ defined $form->field("openid_url") &&
+ length $form->field("openid_url")) {
+ $form->field(
+ name => "openid_url",
+ validate => sub {
+ validate($cgi, $session, shift, $form);
+ },
+ );
+ # Skip all other required fields in this case.
+ foreach my $field ($form->field) {
+ next if $field eq "openid_url";
+ $form->field(name => $field, required => 0,
+ validate => '/.*/');
+ }