plugin => {
safe => 1,
rebuild => 0,
+ section => "auth",
},
openidsignup => {
type => "string",
# OpenID fieldset.
$form->fieldsets("OpenID");
- $form->field(
+ $form->field(
name => "openid_url",
label => gettext("Log in with")." ".htmllink("", "", "ikiwiki/OpenID", noimageinline => 1),
fieldset => "OpenID",
}
}
}
- elsif ($form->title eq "preferences") {
- if (! defined $form->field(name => "name")) {
- $form->field(name => "OpenID", disabled => 1,
- value => $session->param("name"),
- size => 50, force => 1,
- fieldset => "login");
- }
+ elsif ($form->title eq "preferences" &&
+ IkiWiki::openiduser($session->param("name"))) {
+ $form->field(name => "openid_url", disabled => 1,
+ label => htmllink("", "", "ikiwiki/OpenID", noimageinline => 1),
+ value => $session->param("name"),
+ size => 50, force => 1,
+ fieldset => "login");
}
}
);
}
-package IkiWiki;
-
-# This is not used by this plugin, but this seems the best place to put it.
-# Used elsewhere to pretty-display the name of an openid user.
-sub openiduser ($) {
- my $user=shift;
-
- if ($user =~ m!^https?://! &&
- eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) {
- my $display;
-
- if (Net::OpenID::VerifiedIdentity->can("DisplayOfURL")) {
- # this works in at least 2.x
- $display = Net::OpenID::VerifiedIdentity::DisplayOfURL($user);
- }
- else {
- # this only works in 1.x
- my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user);
- $display=$oid->display;
- }
-
- # Convert "user.somehost.com" to "user [somehost.com]"
- # (also "user.somehost.co.uk")
- if ($display !~ /\[/) {
- $display=~s/^([-a-zA-Z0-9]+?)\.([-.a-zA-Z0-9]+\.[a-z]+)$/$1 [$2]/;
- }
- # Convert "http://somehost.com/user" to "user [somehost.com]".
- # (also "https://somehost.com/user/")
- if ($display !~ /\[/) {
- $display=~s/^https?:\/\/(.+)\/([^\/]+)\/?$/$2 [$1]/;
- }
- $display=~s!^https?://!!; # make sure this is removed
- eval q{use CGI 'escapeHTML'};
- error($@) if $@;
- return escapeHTML($display);
- }
- return;
-}
-
1