take username from email address as fallback

master
Joey Hess 2010-06-23 19:36:23 -04:00
parent d8e4b51a41
commit b38b9327a8
1 changed files with 10 additions and 1 deletions

View File

@ -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);