Correcting roles problem - leftover lvalue type access
Jay Kuri [Mon, 18 Dec 2006 19:46:30 +0000 (19:46 +0000)]
lib/Catalyst/Plugin/Authentication/Store/DBIx/Class/User.pm

index 471eab9..9a08fbe 100644 (file)
@@ -15,6 +15,7 @@ sub new {
     my $self = {
         resultset => $c->model($config->{'user_class'}),
         config => $config,
+        _roles => undef,
         _user => undef
     };
     
@@ -101,16 +102,15 @@ sub roles {
     my @roles = ();
     if (exists($self->config->{'role_column'})) {
         @roles = split /[ ,\|]/, $self->get($self->config->{'role_column'});
-        $self->_roles = \@roles;
+        $self->_roles(\@roles);
     } elsif (exists($self->config->{'role_relation'})) {
         my $relation = $self->config->{'role_relation'};
         if ($self->_user->$relation->result_source->has_column($self->config->{'role_field'})) {
-            @roles = $self->_user->$relation->search(undef, { columns => [ $self->config->{'role_field'}]})->all();
+            @roles = map { $_->get_column($self->config->{'role_field'}) } $self->_user->$relation->search(undef, { columns => [ $self->config->{'role_field'}]})->all();
+            $self->_roles(\@roles);
         } else {
             Catalyst::Exception->throw("role table does not have a column called " . $self->config->{'role_field'});
         }
-        my $rolefield = $self->config->{'role_field'};
-        @{$self->_roles} =  map { $_->get_column($self->config->{'role_field'}) } @roles;
     } else {
         Catalyst::Exception->throw("user->roles accessed, but no role configuration found");
     }