]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/openid.pm
refactor check_canchange into IkiWiki library
[git.ikiwiki.info.git] / IkiWiki / Plugin / openid.pm
index 57cb139cae5b82509a59f4300b5d11e03ff9640e..fae9fb77f8388a9e750b1d8e7dfdcee700f76a92 100644 (file)
@@ -42,7 +42,7 @@ sub getsetup () {
                },
                openid_realm => {
                        type => "string",
-                       description => "url of openid realm (default is cgiurl)",
+                       description => "url pattern of openid realm (default is cgiurl)",
                        safe => 0,
                        rebuild => 0,
                },
@@ -187,12 +187,17 @@ sub auth ($$) {
                                        $vident->signed_extension_fields('http://openid.net/srv/ax/1.0'),
                                );
                        }
+                       my $nickname;
                        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 $nickname &&
+                                                   $ext->{$field}=~/(.+)@.+/) {
+                                                       $nickname = $1;
+                                               }
                                                last;
                                        }
                                }
@@ -200,11 +205,15 @@ sub auth ($$) {
                                        if (exists $ext->{$field} &&
                                            defined $ext->{$field} &&
                                            length $ext->{$field}) {
-                                               $session->param(username => $ext->{$field});
+                                               $nickname=$ext->{$field};
                                                last;
                                        }
                                }
                        }
+                       if (defined $nickname) {
+                               $session->param(nickname =>
+                                       Encode::decode_utf8($nickname));
+                       }
                }
                else {
                        error("OpenID failure: ".$csr->err);