Support creating users with no passwords, for OpenID
[scpubgit/stemmatology.git] / 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>.