[Catalyst] Reaction Authentication
Matt S Trout
dbix-class at trout.me.uk
Tue Jan 16 12:34:58 GMT 2007
On 15 Jan 2007, at 18:56, Jonas Alves wrote:
>
>
> On 15/01/07, Jonas Alves <jonas.alves at gmail.com> wrote: On
> 14/01/07, Ash Berlin <ash_cpan at firemirror.com> wrote:
> Jonas Alves wrote:
> > Hi all,
> > I was starting to put authentication in a Reaction application
> that i'm
> > developing when I saw that Reaction has this classes:
> >
> > Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques;
> > Reaction::InterfaceModel::Action::DBIC::User::ChangePassword;
> > Reaction::InterfaceModel::Action::DBIC::User::ResetPassword;
> > Reaction::InterfaceModel::Action::DBIC::User::Role::SetPassword;
> > Reaction::InterfaceModel::Action::User::ChangePassword;
> > Reaction::InterfaceModel::Action::User::ResetPassword;
> > Reaction::InterfaceModel::Action::User::SetPassword;
> >
> > It appears that Reaction already has some facilities to do auth
> stuff.
> > How can I use this classes to help me?
> >
> > Thanks a lot,
> > --
> > Jonas
> >
>
> Not having used Reaction myself BUT I suspect that these are for
> updating existing profile info in the DB.
>
> Do the authentication the same way you would in a normal Catalyst app.
>
> Ash
>
> Thanks Ash,
> I already have authentication the same way i would in a normal
> Catalyst app. But now I would like to use the Reaction TT widgets
> to create a custom form with validation for authentication and
> another one to register a user. I read the source but could not
> achieved it.
> Matt, can you help?
>
> Thanks a lot,
> --
> Jonas
>
>
> Hi again,
> I've now created an Action class do handle the login. Here is the
> code:
>
> package MyApp::Model::Action::AuthUser;
> use Reaction::Class;
> use Reaction::Types::DBIC;
> use Reaction::InterfaceModel::Action;
> use Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques;
>
> class AuthUser is 'Reaction::InterfaceModel::Action', which {
> does 'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques';
> has '+target_model' => (isa => 'DBIx::Class::ResultSet');
has 'username' => (isa => 'NonEmptySimpleStr', is => 'rw',
set_or_lazy_fail('username'));
has 'password' => (isa => 'StrongPassword', is => 'rw',
set_or_lazy_fail('password'));
>
> has _unique_constraint_results => (
> isa => 'HashRef',
> is => 'rw',
> required => 1,
> default => sub { {} },
> metaclass => 'Moose::Meta::Attribute'
> );
>
> implements do_apply => as {
> my $self = shift;
> my $args = $self->parameter_hashref;
> warn '==> ' .Dumper $args;
> # do auth stuff here
> };
> };
>
> 1;
> But the form is rendered just with the "ok" and "close" buttons.
> The fields are not displayed.
> I put some debug in ActionForm.pm BUILD method and found that $self-
> >_has_field_map() is always false and $action->parameter_attributes
> () does not return anything.
> What am i doing wrong?
>
You have to put the attributes within the class block or the
superclass hasn't been set yet, which means the attributes default to
the wrong meta-attribute class and aren't created as
ParameterAttribute objects. At which point, it doesn't work :)
--
Matt S Trout, Technical Director, Shadowcat Systems Ltd.
Offering custom development, consultancy and support contracts for
Catalyst,
DBIx::Class and BAST. Contact mst (at) shadowcatsystems.co.uk for
details.
+ Help us build a better perl ORM: http://dbix-
class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list