typo in exception line. fixed
[catagits/Catalyst-Authentication-Store-DBIx-Class.git] / lib / Catalyst / Authentication / Store / DBIx / Class / User.pm
index 239b022..caf64af 100644 (file)
@@ -31,6 +31,9 @@ sub new {
             Catalyst::Exception->throw("user table does not contain a single primary key column - please specify 'id_field' in config!");
         }
     }
+    if (not $self->{'resultset'}) {
+        Catalyst::Exception->throw("\$c->model('${ \$self->config->{user_class} }') did not return a resultset. Did you set user_class correctly?");
+    }
     if (!$self->{'resultset'}->result_source->has_column($self->config->{'id_field'})) {
         Catalyst::Exception->throw("id_field set to " .  $self->config->{'id_field'} . " but user table has no column by that name!");
     }
@@ -80,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::Exception->throw("User retrieval failed: no columns from " . $self->config->{'user_class'} . " were provided");
+        }
     }
 
     if ($self->get_object) {
@@ -115,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'})) {
@@ -267,13 +274,11 @@ Returns an array of roles associated with this user, if roles are configured for
 
 =head2 for_session
 
-Returns a serialized user for storage in the session.  Currently, this is the value of the field
-specified by the 'id_field' config variable.
+Returns a serialized user for storage in the session.  
 
 =head2 from_session
 
-Revives a serialized user from storage in the session.  Currently, this uses the serialized data as the
-value of the 'id_field' config variable.
+Revives a serialized user from storage in the session. 
 
 =head2 get ( $fieldname )