Re: [Catalyst] Reaction Authentication

2007-01-29 Thread Guillermo Roditi

Role's don't do augment. I'll look further into this though

On 1/29/07, Jonas Alves [EMAIL PROTECTED] wrote:




On 28/01/07, Guillermo Roditi [EMAIL PROTECTED] wrote:
 FIXED IT!!!

 take out the does '...' line and replace it with this:

 override parameter_hashref = sub{
 my $self = shift;
 my $args = super();
 $args-{password} = delete $args-{new_password};
 delete $args-{confirm_new_password};
 return $args;
 };


 here's my class:

 package Prefab::Model::Action::CreateUser;

 use strict;
 use warnings;

 use Reaction::Class;
 use aliased
'Reaction::InterfaceModel::Action::DBIC::ActionReflector';

 extends qw(

Reaction::InterfaceModel::Action::User::SetPassword

Reaction::InterfaceModel::Action::DBIC::ResultSet::Create
   );

 my $r = ActionReflector-new;
 $r-reflect_attrs('Prefab::Schema::User'  =
__PACKAGE__,
   qw/id username created_d role_list/);

 override parameter_hashref = sub{
 my $self = shift;
 my $args = super();
 $args-{password} = delete $args-{new_password};
 delete $args-{confirm_new_password};
 return $args;
 };

 1;



 If you want to reflect fields like i did then add this method to
 action reflector:

   implements reflect_attrs = as {
 my ($self, $from_class, $to_class, @attrs) = @_;
 foreach my $attr_name (@attrs) {
   $self-reflect_attribute_to($from_class,

$from_class-meta-get_attribute($attr_name),
   $to_class);
 }
   };

Cool, I like that reflect_attrs method, I'm already using it.
I have tried your aproach before. You can't delete the 'new_password' and
'confirm_new_password' or the confirm_password is not checked against
'new_password'.
You have to live with the warnings in the error log.
But it doesn't work for me either. The problem is that
Reaction::InterfaceModel::Action::User::SetPassword and
Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques
both override 'error_for_attribute' and 'can_apply'. So if you have unique
constraints in your schema they don't get evaluated if your class extends
from User::SetPassword before ResultSet::Create
or if you reverse the order then your confirm password is not checked. I
tried to change the methods from override to augment and the super() call to
an inner() call but i got following error:
Moose::Role cannot support 'augment' at
/usr/local/share/perl/5.8.7/Moose/Role.pm line 138

So i don't know how to fix this.

--
Jonas


___
List: Catalyst@lists.rawmode.org
Listinfo:
http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/





___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-29 Thread Matt S Trout


On 29 Jan 2007, at 13:12, Jonas Alves wrote:


I have tried your aproach before. You can't delete the  
'new_password' and 'confirm_new_password' or the confirm_password  
is not checked against 'new_password'.

You have to live with the warnings in the error log.
But it doesn't work for me either. The problem is that  
Reaction::InterfaceModel::Action::User::SetPassword and  
Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques both  
override 'error_for_attribute' and 'can_apply'. So if you have  
unique constraints in your schema they don't get evaluated if your  
class extends from User::SetPassword before ResultSet::Create
or if you reverse the order then your confirm password is not  
checked. I tried to change the methods from override to augment and  
the super() call to an inner() call but i got following error:
Moose::Role cannot support 'augment' at /usr/local/share/perl/5.8.7/ 
Moose/Role.pm line 138




We almost certainly want to be using roles for all of this with around 
() so it can wrap in-place and doesn't automatically jump to superclass.


The current user stuff is mostly a very simple convenience API that  
needs its guts factoring out into more easily composable components.  
Patches to do so welcome :)


--
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/ +




___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-27 Thread Guillermo Roditi

FIXED IT!!!

take out the does '...' line and replace it with this:

override parameter_hashref = sub{
   my $self = shift;
   my $args = super();
   $args-{password} = delete $args-{new_password};
   delete $args-{confirm_new_password};
   return $args;
};


here's my class:

package Prefab::Model::Action::CreateUser;

use strict;
use warnings;

use Reaction::Class;
use aliased 'Reaction::InterfaceModel::Action::DBIC::ActionReflector';

extends qw(
  Reaction::InterfaceModel::Action::User::SetPassword
  Reaction::InterfaceModel::Action::DBIC::ResultSet::Create
 );

my $r = ActionReflector-new;
$r-reflect_attrs('Prefab::Schema::User'  =  __PACKAGE__,
 qw/id username created_d role_list/);

override parameter_hashref = sub{
   my $self = shift;
   my $args = super();
   $args-{password} = delete $args-{new_password};
   delete $args-{confirm_new_password};
   return $args;
};

1;



If you want to reflect fields like i did then add this method to
action reflector:

 implements reflect_attrs = as {
   my ($self, $from_class, $to_class, @attrs) = @_;
   foreach my $attr_name (@attrs) {
 $self-reflect_attribute_to($from_class,
 $from_class-meta-get_attribute($attr_name),
 $to_class);
   }
 };




On 1/27/07, Guillermo Roditi [EMAIL PROTECTED] wrote:

I just ran into this bug too

target_model isa = 'ResultSet' on Create, not a Row, so it lacks a
password field. it is mildly retarded. i dont know how to fix it in an
elegant manner.. but at least i know now what the problem is...

if i get lucky this will probably be fixed in svn soonish

On 1/25/07, Jonas Alves [EMAIL PROTECTED] wrote:


 On 25/01/07, Guillermo Roditi [EMAIL PROTECTED] wrote:
  what i meant is that you get new_password and confirm_new password,
  but you still need the original password field
 
  see code for
 Reaction::InterfaceModel::Action::DBIC::User::Role::SetPassword;

  Yes, but i have the password field in the model passed to target_model.



 ___
 List: Catalyst@lists.rawmode.org
 Listinfo:
 http://lists.rawmode.org/mailman/listinfo/catalyst
 Searchable archive:
 http://www.mail-archive.com/catalyst@lists.rawmode.org/
 Dev site: http://dev.catalyst.perl.org/






___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-25 Thread Guillermo Roditi

it's new_password and confirm_new_password

with new_ prepended. that's why it's failing

On 1/25/07, Jonas Alves [EMAIL PROTECTED] wrote:



On 25/01/07, Jonas Alves [EMAIL PROTECTED] wrote:



 On 25/01/07, Matt S Trout  [EMAIL PROTECTED] wrote:
 
  On 25 Jan 2007, at 12:55, Jonas Alves wrote:
 
  
  
   On 23/01/07, Guillermo Roditi [EMAIL PROTECTED]  wrote: Hey, any
   chance you could post the working code now that you fixed it.
  
   There is no actual real working code for reaction out there, and
   it'd be nice to look at some real code..
  
   in other words, can I see your finished action and controller
   classes so i can steal ideas and learn something?
  
   I am working on a reaction app that I will post to public SVN as
   soon as it actually runs and keep it public as i develop it so
   other people can get an idea aswell
  
   Hi Guillermo,
   The application that I'm developing is for a client so I can't make
   it public. But here are the pertinent action classes and
   controllers that i have for now:
 
  Any particular reason you aren't using the existing SetPassword roles
  etc. ?


 Ups, I guess i missed that one. I will update my code to use it. Thanks :D

Hum, I can't make it work.
This is what i have:

package OliveiraDaSerra::Model::Action::CreateUser;
use Reaction::Class;

extends qw(

Reaction::InterfaceModel::Action::DBIC::ResultSet::Create
Reaction::InterfaceModel::Action::User::SetPassword
);

does
'Reaction::InterfaceModel::Action::DBIC::User::Role::SetPassword';

has 'email_address' = (isa = 'EmailAddress', is = 'rw',
set_or_lazy_fail('email_address'));
#has 'password'  = (isa = 'StrongPassword', is = 'rw');
#has 'confirm_password' = (isa = 'StrongPassword', is = 'rw');
has 'last_name' = (isa = 'NonEmptySimpleStr', is = 'rw', predicate =
'has_last_name');
has 'first_name'= (isa = 'NonEmptySimpleStr', is = 'rw',
set_or_lazy_fail('first_name'));
has 'username'  = (isa = 'NonEmptySimpleStr', is = 'rw',
set_or_lazy_fail('username'));

#override parameter_hashref = sub {
#my $hash = super();
#$hash-{password} = delete $hash-{new_password};
#delete $hash-{confirm_new_password};
#return $hash;
#};

1;

But i get this error: Can't locate object method password via package
DBIx::Class::ResultSet at
/usr/local/share/perl/5.8.7/Reaction/InterfaceModel/Action/DBIC/User/Role/SetPassword.pm
line 8.

What am i doing wrong?

--
Jonas




___
List: Catalyst@lists.rawmode.org
Listinfo:
http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/





___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-25 Thread Guillermo Roditi

what i meant is that you get new_password and confirm_new password,
but you still need the original password field

see code for Reaction::InterfaceModel::Action::DBIC::User::Role::SetPassword;


On 1/25/07, Guillermo Roditi [EMAIL PROTECTED] wrote:

it's new_password and confirm_new_password

with new_ prepended. that's why it's failing

On 1/25/07, Jonas Alves [EMAIL PROTECTED] wrote:


 On 25/01/07, Jonas Alves [EMAIL PROTECTED] wrote:
 
 
 
  On 25/01/07, Matt S Trout  [EMAIL PROTECTED] wrote:
  
   On 25 Jan 2007, at 12:55, Jonas Alves wrote:
  
   
   
On 23/01/07, Guillermo Roditi [EMAIL PROTECTED]  wrote: Hey, any
chance you could post the working code now that you fixed it.
   
There is no actual real working code for reaction out there, and
it'd be nice to look at some real code..
   
in other words, can I see your finished action and controller
classes so i can steal ideas and learn something?
   
I am working on a reaction app that I will post to public SVN as
soon as it actually runs and keep it public as i develop it so
other people can get an idea aswell
   
Hi Guillermo,
The application that I'm developing is for a client so I can't make
it public. But here are the pertinent action classes and
controllers that i have for now:
  
   Any particular reason you aren't using the existing SetPassword roles
   etc. ?
 
 
  Ups, I guess i missed that one. I will update my code to use it. Thanks :D

 Hum, I can't make it work.
 This is what i have:

 package OliveiraDaSerra::Model::Action::CreateUser;
 use Reaction::Class;

 extends qw(

 Reaction::InterfaceModel::Action::DBIC::ResultSet::Create
 Reaction::InterfaceModel::Action::User::SetPassword
 );

 does
 'Reaction::InterfaceModel::Action::DBIC::User::Role::SetPassword';

 has 'email_address' = (isa = 'EmailAddress', is = 'rw',
 set_or_lazy_fail('email_address'));
 #has 'password'  = (isa = 'StrongPassword', is = 'rw');
 #has 'confirm_password' = (isa = 'StrongPassword', is = 'rw');
 has 'last_name' = (isa = 'NonEmptySimpleStr', is = 'rw', predicate =
 'has_last_name');
 has 'first_name'= (isa = 'NonEmptySimpleStr', is = 'rw',
 set_or_lazy_fail('first_name'));
 has 'username'  = (isa = 'NonEmptySimpleStr', is = 'rw',
 set_or_lazy_fail('username'));

 #override parameter_hashref = sub {
 #my $hash = super();
 #$hash-{password} = delete $hash-{new_password};
 #delete $hash-{confirm_new_password};
 #return $hash;
 #};

 1;

 But i get this error: Can't locate object method password via package
 DBIx::Class::ResultSet at
 
/usr/local/share/perl/5.8.7/Reaction/InterfaceModel/Action/DBIC/User/Role/SetPassword.pm
 line 8.

 What am i doing wrong?

 --
 Jonas




 ___
 List: Catalyst@lists.rawmode.org
 Listinfo:
 http://lists.rawmode.org/mailman/listinfo/catalyst
 Searchable archive:
 http://www.mail-archive.com/catalyst@lists.rawmode.org/
 Dev site: http://dev.catalyst.perl.org/






___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-25 Thread Jonas Alves

On 25/01/07, Guillermo Roditi [EMAIL PROTECTED] wrote:


what i meant is that you get new_password and confirm_new password,
but you still need the original password field

see code for
Reaction::InterfaceModel::Action::DBIC::User::Role::SetPassword;



Yes, but i have the password field in the model passed to target_model.
___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-23 Thread Guillermo Roditi

Hey, any chance you could post the working code now that you fixed it.

There is no actual real working code for reaction out there, and it'd be
nice to look at some real code..

in other words, can I see your finished action and controller classes so i
can steal ideas and learn something?

I am working on a reaction app that I will post to public SVN as soon as it
actually runs and keep it public as i develop it so other people can get an
idea aswell

On 1/16/07, Jonas Alves [EMAIL PROTECTED] wrote:




On 16/01/07, Matt S Trout [EMAIL PROTECTED] wrote:


 On 15 Jan 2007, at 18:56, Jonas Alves wrote:

 
 
  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;
 

  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 :)


It makes sense.
Thanks a lot Matt. :)


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/



___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-16 Thread Matt S Trout


On 15 Jan 2007, at 18:56, Jonas Alves wrote:




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;




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/ +




___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-16 Thread Jonas Alves

On 16/01/07, Matt S Trout [EMAIL PROTECTED] wrote:



On 15 Jan 2007, at 18:56, Jonas Alves wrote:



 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;


 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 :)



It makes sense.
Thanks a lot Matt. :)
___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-15 Thread Jonas Alves

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
___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reaction Authentication

2007-01-15 Thread Jonas Alves

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: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Reaction Authentication

2007-01-14 Thread Jonas Alves

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
___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/