On 15/01/07, Jonas Alves <[EMAIL PROTECTED]> wrote:
On 14/01/07, Ash Berlin <[EMAIL PROTECTED]> 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;
has 'username' => (isa => 'NonEmptySimpleStr', is => 'rw',
set_or_lazy_fail('username'));
has 'password' => (isa => 'StrongPassword', is => 'rw',
set_or_lazy_fail('password'));
class AuthUser is 'Reaction::InterfaceModel::Action', which {
does 'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques';
has '+target_model' => (isa => 'DBIx::Class::ResultSet');
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;
And a controller to handle it:
package MyApp::Controller::Login;
use strict;
use warnings;
use base 'Reaction::UI::CRUDController';
use Reaction::Class;
use aliased 'Reaction::UI::ViewPort::ListView';
use aliased 'Reaction::UI::ViewPort::ActionForm';
use aliased 'Reaction::UI::ViewPort';
__PACKAGE__->config(
action => { base => { Chained => '/base', PathPart => 'login' },
login => { ViewPort => { layout => 'login_form' } },
},
);
sub base :Action :CaptureArgs(0) {
my ($self, $c) = @_;
}
sub login :Chained('base') :PathPart('') :Args(0) {
my ($self, $c) = @_;
my $action = $c->model('Action::AuthUser')
->new( target_model => $c->model('DBIC::User'), ctx => $c,);
$self->push_viewport(
ActionForm,
action => $action,
#next_action => 'list',
);
}
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?
Hope you can help me.
--
Jonas
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/