+sub openid_selector {
+ my $real_cgi_signin=shift;
+ my $q=shift;
+ my $session=shift;
+
+ my $openid_url=$q->param('openid_url');
+ my $openid_error;
+
+ if (defined $q->param("action") && $q->param("action") eq "verify") {
+ validate($q, $session, $openid_url, sub {
+ $openid_error=shift;
+ });
+ }
+ elsif ($q->param("do") eq "signin" || ! load_openid_module()) {
+ $real_cgi_signin->($q, $session);
+ exit;
+ }
+
+ my $template=IkiWiki::template("openid-selector.tmpl");
+ $template->param(
+ cgiurl => $config{cgiurl},
+ (defined $openid_error ? (openid_error => $openid_error) : ()),
+ (defined $openid_url ? (openid_url => $openid_url) : ()),
+ # TODO only if other auth methods are available
+ nonopenidurl => IkiWiki::cgiurl(do => "signin"),
+ loginlabel => loginlabel(),
+ );
+
+ IkiWiki::printheader($session);
+ print IkiWiki::misctemplate("signin", $template->output);
+ exit;
+}
+