]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/openid.pm
thoughts
[git.ikiwiki.info.git] / IkiWiki / Plugin / openid.pm
index 3b96e4b8e411c5f29afc25b58e15cdfd9f70121d..00652ebb7db2034b5785cd27b2c1fb7aacf545e8 100644 (file)
@@ -25,11 +25,15 @@ sub checkconfig () {
                # a reference to the normal signin form.
                require IkiWiki::CGI;
                my $real_cgi_signin;
+               my $nonopenidform_label=gettext("Other");
                if (keys %{$IkiWiki::hooks{auth}} > 1) {
                        $real_cgi_signin=\&IkiWiki::cgi_signin;
+                       if (keys %{$IkiWiki::hooks{auth}} == 2 && exists $IkiWiki::hooks{auth}->{passwordauth}) {
+                               $nonopenidform_label=gettext("Password");
+                       }
                }
                inject(name => "IkiWiki::cgi_signin", call => sub ($$) {
-                       openid_selector($real_cgi_signin, @_);
+                       openid_selector($real_cgi_signin, $nonopenidform_label, @_);
                });
        }
 }
@@ -57,6 +61,7 @@ sub getsetup () {
 
 sub openid_selector {
        my $real_cgi_signin=shift;
+       my $nonopenidform_label=shift;
         my $q=shift;
         my $session=shift;
 
@@ -82,6 +87,7 @@ sub openid_selector {
                (defined $openid_error ? (openid_error => $openid_error) : ()),
                (defined $openid_url ? (openid_url => $openid_url) : ()),
                ($real_cgi_signin ? (nonopenidform => $real_cgi_signin->($q, $session, 1)) : ()),
+               nonopenidform_label => $nonopenidform_label,
        );
 
        IkiWiki::printheader($session);
@@ -104,7 +110,6 @@ sub formbuilder_setup (@) {
                        size => 1, force => 1,
                        fieldset => "login",
                        comment => $session->param("name"));
-               $form->field(name => "email", type => "hidden");
        }
 }
 
@@ -119,7 +124,9 @@ sub validate ($$$;$) {
        my $claimed_identity = $csr->claimed_identity($openid_url);
        if (! $claimed_identity) {
                if ($errhandler) {
-                       $errhandler->($csr->err);
+                       if (ref($errhandler) eq 'CODE') {
+                               $errhandler->($csr->err);
+                       }
                        return 0;
                }
                else {
@@ -223,7 +230,7 @@ sub auth ($$) {
        }
        elsif (defined $q->param('openid_identifier')) {
                # myopenid.com affiliate support
-               validate($q, $session, $q->param('openid_identifier'));
+               validate($q, $session, scalar $q->param('openid_identifier'));
        }
 }