Be more descriptive about failure when no valid fields were defined in
Jay Kuri [Mon, 21 Jul 2008 22:28:31 +0000 (22:28 +0000)]
the authinfo hash (passed to $c->authenticate() )

allow any whitespace to separate roles in the roles column

Changes
lib/Catalyst/Authentication/Store/DBIx/Class/User.pm

diff --git a/Changes b/Changes
index 82df0ba..d6e38b5 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,11 @@
 Revision history for Catalyst-Plugin-Authentication-Store-DBIx-Class
 
+0.105   2008-03-19
+        Throw an exception if no fields are provided during authenticate
+           - better than retrieving a random user. 
+           - still possible to do an empty search by using searchargs
+        
+
 0.104   2008-02-15
         Added ability to avoid DB hits when restoring from session
 
index 6487ae1..a82b37c 100644 (file)
@@ -83,7 +83,11 @@ sub load {
                 $searchargs->{$key} = $authinfo->{$key};
             }
         }
-        $self->_user($self->resultset->search($searchargs)->first);
+        if (keys %{$searchargs}) {
+            $self->_user($self->resultset->search($searchargs)->first);
+        } else {
+            Catalyst::Exeption->throw("User retrieval failed: no columns from " . $self->config->{'user_class'} . " were provided");
+        }
     }
 
     if ($self->get_object) {
@@ -118,7 +122,7 @@ sub roles {
     if (exists($self->config->{'role_column'})) {
         my $role_data = $self->get($self->config->{'role_column'});
         if ($role_data) { 
-            @roles = split /[ ,\|]+/, $self->get($self->config->{'role_column'});
+            @roles = split /[\s,\|]+/, $self->get($self->config->{'role_column'});
         }
         $self->_roles(\@roles);
     } elsif (exists($self->config->{'role_relation'})) {