Support creating users with no passwords, for OpenID
Jess Robinson [Tue, 15 May 2012 16:27:41 +0000 (16:27 +0000)]
(probably could be cleaner)

lib/Text/Tradition/UserStore.pm

index 5493d82..783bdc8 100644 (file)
@@ -79,14 +79,15 @@ Create a new user object, store in the KiokuDB backend, and return it.
 
 sub add_user {
     my ($self, $userinfo) = @_;
-    my $username = $userinfo->{username};
+    my $username = $userinfo->{url} || $userinfo->{username};
     my $password = $userinfo->{password};
 
-    return unless $username && $self->validate_password($password);
+    return unless ($username =~ /^https?:/ 
+                   || ($username && $self->validate_password($password))) ;
 
     my $user = Text::Tradition::User->new(
         id => $username,
-        password => crypt_password($password),
+        password => ($password ? crypt_password($password) : ''),
     );
 
     my $scope = $self->new_scope;
@@ -95,6 +96,11 @@ sub add_user {
     return $user;
 }
 
+sub create_user {
+    my $self = shift;
+    return $self->add_user(@_);
+}
+
 =head3 find_user
 
 Takes a hashref of C<username>, optionally C<openid_identifier>.