[Catalyst] Authentication::Store::DBIC => Can't call method "search" in uthentication::Store::DBIC::User ???

T. H. Lin easy.lin at gmail.com
Sun Apr 23 17:25:34 CEST 2006


On 23/04/06, Yuval Kogman <nothingmuch at woobling.org> wrote:
> On Sun, Apr 23, 2006 at 03:06:37 +0200, T. H. Lin wrote:
> > It seems
> > __PACKAGE__->config->{authentication}{dbic} = {
> >          user_class               => 'DBIC::User',
> >          user_field                 => 'name',
> >          password_field        => 'pass',
> >          password_type         => 'hashed',
> >          password_hash_type => 'SHA-256',
> >      };
> > must be defined in MyApp.pm(and before __PACKAGE__->setup !!)
> >
> > but....
> > I have 2 tables for two different type of account,
> > (for some reason, I make 2 tables, do not use role method)
> >
> > MyApp/C/basic_account.pm
> > MyApp/C/advanced_account.pm
> >
> > I would like to define different user_class in basic_account.pm and
> > advanced_account.pm.
> >
> >is it possible?
>
> I agree with what John said, but there is support for this.
>
> If you can't use role based access control
> (Catalyst::Plugin::Authorization::Roles) then you can use the
> non-easy interface into the authentication stores:
>
> Initialize your own Catalyst::Plugin::Authentication::DBIC::Backend
> (read the source code to see how this is done - each store may
> require a different initialization sequence), register it, and then
> create another, and register it by another name:
>
>         register_autho_stores(
>                 basic => $backend,
>                 advanced => $backend,
>         );
>
> Note that at this stage there is no store by the name of 'default' -
> this means you have to use user objects. Instead of
>
>         $c->login( "user", "password" ); # two string
>
> You need to say
>
>         my $user = $c->get_auth_store("basic")->get_user($username);
>         $c->login( $user, $password );
>
> and all the session integration will continue to work normally from
> here, mapping to the right store.
>
> You might want to put a multiplexing store in 'default', one that
> will first try one store and then the other.
>
> --
>   Yuval Kogman <nothingmuch at woobling.org>
> http://nothingmuch.woobling.org  0xEBD27418
thanks for the advice and the short tutorial. :-)

In my design the basic_user and advanced_user are two totally different account,
they have only some the same property(name, birthday, location...)
Their relationship with other tables never overlap.
And two accounts have totally diefferent privilege.
Their activities in web also never overlap.
hence, I design them in 2 table.

maybe it is not a good design pattern....

anyway, I will go to try out Kogman's method.



More information about the Catalyst mailing list