From: Jay Kuri Date: Mon, 21 Jul 2008 22:28:31 +0000 (+0000) Subject: Be more descriptive about failure when no valid fields were defined in X-Git-Tag: v0.1100~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Authentication-Store-DBIx-Class.git;a=commitdiff_plain;h=87920e6481fec132144cf9fe3b25c339b1032af6 Be more descriptive about failure when no valid fields were defined in the authinfo hash (passed to $c->authenticate() ) allow any whitespace to separate roles in the roles column --- diff --git a/Changes b/Changes index 82df0ba..d6e38b5 100644 --- 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 diff --git a/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm b/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm index 6487ae1..a82b37c 100644 --- a/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm +++ b/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm @@ -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'})) {