From: Joey Hess Date: Wed, 23 Jun 2010 23:36:23 +0000 (-0400) Subject: take username from email address as fallback X-Git-Tag: 3.20100704~36 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b38b9327a8f11b642e5f51f7ee537043e25ccff9;p=ikiwiki.git take username from email address as fallback --- diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index f4ba8db18..f19a559a9 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -187,12 +187,17 @@ sub auth ($$) { $vident->signed_extension_fields('http://openid.net/srv/ax/1.0'), ); } + my $username; foreach my $ext (@extensions) { foreach my $field (qw{value.email email}) { if (exists $ext->{$field} && defined $ext->{$field} && length $ext->{$field}) { $session->param(email => $ext->{$field}); + if (! defined $username && + $ext->{$field}=~/(.+)@.+/) { + $username = $1; + } last; } } @@ -200,11 +205,15 @@ sub auth ($$) { if (exists $ext->{$field} && defined $ext->{$field} && length $ext->{$field}) { - $session->param(username => $ext->{$field}); + $username=$ext->{$field}; last; } } } + if (defined $username) { + $username=~s/\s+/_/g; + $session->param(username => $username); + } } else { error("OpenID failure: ".$csr->err);