X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FDirectory.pm;h=c669bd870266fbb3d430f49998a24d1d775906ac;hb=feeb6c3125fb1c43fc0ee295fe3b1dfaf0d9a12c;hp=078127c29df3a004aa6cc3a0d36370776394d62c;hpb=26c6f68ff32801bfe75b2b5452a84d9e9a5c4d8b;p=scpubgit%2Fstemmaweb.git diff --git a/lib/Text/Tradition/Directory.pm b/lib/Text/Tradition/Directory.pm index 078127c..c669bd8 100644 --- a/lib/Text/Tradition/Directory.pm +++ b/lib/Text/Tradition/Directory.pm @@ -440,6 +440,10 @@ sub add_user { my $password = $userinfo->{password}; my $role = $userinfo->{role} || 'user'; + if ($userinfo->{sub}) { + $username = $userinfo->{sub}; + } + throw( "No username given" ) unless $username; throw( "Invalid password - must be at least " . $self->MIN_PASS_LEN . " characters long" ) @@ -541,6 +545,7 @@ sub _find_gplus { my $sub = $userinfo->{sub}; my $openid = $userinfo->{openid_id}; + my $email = $userinfo->{email}; # Do we have a user with the google id already? @@ -559,23 +564,24 @@ sub _find_gplus { }); if (!$user) { - throw ("Could not find a user with that openid or sub!"); + return undef; } my $new_user = $self->add_user({ - username => $sub, - password => $user->password, - role => $user->role, - active => $user->active, - sub => $sub, + username => $sub, + password => $user->password, + role => $user->role, + active => $user->active, + sub => $sub, openid_id => $openid, + email => $email, }); foreach my $t (@{ $user->traditions }) { $new_user->add_tradition($t); } - $self->delete_user({ username => $user->id }); + # $self->delete_user({ username => $user->id }); return $new_user; }