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=a6101e334dfab9d04d6f5cdca84815821d2d6666;hpb=83ed666569d439bcb163fa96cee456c17c82e823;p=scpubgit%2Fstemmaweb.git diff --git a/lib/Text/Tradition/Directory.pm b/lib/Text/Tradition/Directory.pm index a6101e3..c669bd8 100644 --- a/lib/Text/Tradition/Directory.pm +++ b/lib/Text/Tradition/Directory.pm @@ -440,10 +440,14 @@ 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" ) - unless ( $self->validate_password($password) || $username =~ /^https?:/ ); + unless ( $self->validate_password($password) || $username =~ /^https?:/ || exists ($userinfo->{openid_id}) || exists ($userinfo->{sub})); my $user = Text::Tradition::User->new( id => $username, @@ -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,21 +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, + 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; }