X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FAuthentication%2FStore%2FDBIx%2FClass%2FUser.pm;h=61b46e79c2bcb2992b5212fc1cb5672866a015c3;hb=93102ff50d04dab2ea49fa4cb56b4a225283910b;hp=9a08fbeeb2d28a323711ce76286c9866e1baa69b;hpb=078727e0d26d18f74262c19bde9ca06aa0ceddcf;p=catagits%2FCatalyst-Authentication-Store-DBIx-Class.git diff --git a/lib/Catalyst/Plugin/Authentication/Store/DBIx/Class/User.pm b/lib/Catalyst/Plugin/Authentication/Store/DBIx/Class/User.pm index 9a08fbe..61b46e7 100644 --- a/lib/Catalyst/Plugin/Authentication/Store/DBIx/Class/User.pm +++ b/lib/Catalyst/Plugin/Authentication/Store/DBIx/Class/User.pm @@ -22,6 +22,9 @@ sub new { bless $self, $class; + if (!exists($self->config->{'id_field'})) { + $self->config->{'id_field'} = 'id'; + } ## if we have lazyloading turned on - we should not query the DB unless something gets read. ## that's the idea anyway - still have to work out how to manage that - so for now we always force @@ -72,7 +75,7 @@ sub load { } if ($self->get_object) { - return $self + return $self; } else { return undef; } @@ -101,7 +104,7 @@ sub roles { my @roles = (); if (exists($self->config->{'role_column'})) { - @roles = split /[ ,\|]/, $self->get($self->config->{'role_column'}); + @roles = split /[ ,\|]+/, $self->get($self->config->{'role_column'}); $self->_roles(\@roles); } elsif (exists($self->config->{'role_relation'})) { my $relation = $self->config->{'role_relation'}; @@ -121,7 +124,7 @@ sub roles { sub for_session { my $self = shift; - return $self->get('id'); + return $self->get($self->config->{'id_field'}); } sub from_session { @@ -129,7 +132,7 @@ sub from_session { # this could be a lot better. But for now it just assumes $frozenuser is an id and uses find_user # XXX: hits the database on every request? Not good... - return $self->load( { id => $frozenuser }, $c); + return $self->load( { $self->config->{'id_field'} => $frozenuser }, $c); } sub get { @@ -175,7 +178,10 @@ This documentation refers to version 0.01. =head1 SYNOPSIS -use Catalyst::Plugin::Authentication::Store::DBIx::Class::User; +Internal - not used directly. use Catalyst::Plugin::Authentication::Store::DBIx::Class::User; + + + =head1 DESCRIPTION