Hi There Ashley,
The DBIx::Class module expects to use the relation provided in the
role_relation config element to retrieve one or more rows, which must
contain a field called by whatever you provide in role_field.
My guess is that your user_roles table is a cross-ref table - userid
and roleid essentially. In order to solve this you need to use a
many_to_many relationship mapping to the textual role names.
The DBIx::Class module expects you are going to route it to the
information it needs using the role_relation. So what you really need
to do is create the schema class and just define the many-to-many for
roles. Then provide that relation to 'role_relation' and all your
problems should go away.
It still works with dynamic schema - but you have to create the
relationship. You can do that by creating your schema module to look
something like this:
package MyApp::Schema::Users;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("PK::Auto", "Core");
__PACKAGE__->has_many('roles_map', "MyApp::Schema::RoleMap", user_id');
__PACKAGE__->many_to_many( roles => 'role_map, 'role');
1;
I might have that slightly wrong - I've been moving today so I'm a bit
overtired. but basically that allows your schema to dynamically
figure itself out, but you define the relationships for it.
For some database types, DBIx::Class can figure out your relationships
for you - but I don't think it can sort out many-to-many's anyway.
Hope that helps. And I hope it makes as much sense to you as I make
to myself in my head at the moment. This, I understand, may not be
the case. If not, I'll try again tomorrow.
Jay
On Dec 15, 2007, at 5:57 PM, Ashley Pond V wrote:
Progressing… Looking at Catalyst/Plugin/Authentication/Store/DBIC/
User.pm I saw a couple of items in the "authentication" config I
could set. With "role_relation" and "role_field" set--
authentication:
default_realm: users
realms:
users:
credential:
class: Password
password_field: password
password_type: hashed
password_hash_type: SHA-1
store:
class: DBIx::Class
user_class: User
role_relation: user_roles
role_field: role
--I now get the roles checked but they are failing because they are
checking (returning) the role "id" instead of the "name."
$c->user->roles returns a list of the IDs too. So, from reading this,
Catalyst::Plugin::Authentication::Store::DBIx::Class::roles()
it looks like dynamic loader schemas are incompatible right now? I'm
trying to figure this out but there is a lot of inter-related code
to read, cross-package-configuration, and documentation drift/lag.
Throw me a bone, er, a line!
-Ashley
On Dec 15, 2007, at 10:18 AM, Ashley Pond V wrote:
Can you elaborate? "map_user_role" ne "user_role." I have
"role_rel" set to the UserRole class. I tried adding "user_role"
but it didn't help and I don't see it anywhere in the docs.
I should rephrase, I think. Is anyone using DBIC::Schema::Loader
dynamically with role authorization? If so, please share your
configuration or advise of which FMTR.
Thanks again,
-Ashley
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/
---
For most things, throwing yourself at the wall over and over is a
better way to improve than thinking hard about the wall and taking
pictures of it. -- D.Litwack
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/