[Catalyst-commits] r10465 - in
Catalyst-Plugin-Authentication/0.10000/branches/moose: .
lib/Catalyst/Authentication lib/Catalyst/Authentication/Credential
lib/Catalyst/Authentication/Realm lib/Catalyst/Authentication/Store
lib/Catalyst/Authentication/User lib/Catalyst/Plugin
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sun Jun 7 03:26:14 GMT 2009
Author: t0m
Date: 2009-06-07 03:26:14 +0000 (Sun, 07 Jun 2009)
New Revision: 10465
Modified:
Catalyst-Plugin-Authentication/0.10000/branches/moose/Makefile.PL
Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Credential/Password.pm
Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Realm.pm
Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Realm/Progressive.pm
Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Store/Minimal.pm
Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Store/Null.pm
Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/User.pm
Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/User/Hash.pm
Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Plugin/Authentication.pm
Log:
Convert most of the classes to basic Moose. Those which used to use CAF need the CAF role adding for back compat
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/Makefile.PL
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/Makefile.PL 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/Makefile.PL 2009-06-07 03:26:14 UTC (rev 10465)
@@ -9,7 +9,9 @@
name 'Catalyst-Plugin-Authentication';
all_from 'lib/Catalyst/Plugin/Authentication.pm';
-requires 'Catalyst::Runtime';
+requires 'Moose' => '0.78';
+requires 'namespace::autoclean' => '0.05';
+requires 'Catalyst::Runtime' => '5.80004';
requires 'Class::Inspector';
requires 'MRO::Compat';
requires 'Catalyst::Plugin::Session' => '0.10';
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Credential/Password.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Credential/Password.pm 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Credential/Password.pm 2009-06-07 03:26:14 UTC (rev 10465)
@@ -1,26 +1,21 @@
package Catalyst::Authentication::Credential::Password;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
-
-use base qw/Class::Accessor::Fast/;
-
use Scalar::Util ();
use Catalyst::Exception ();
use Digest ();
-BEGIN {
- __PACKAGE__->mk_accessors(qw/_config realm/);
-}
+has [qw/_config realm/] => ( is => 'rw' );
-sub new {
+sub BUILDARGS {
my ($class, $config, $app, $realm) = @_;
- my $self = { _config => $config };
- bless $self, $class;
-
- $self->realm($realm);
-
+ { realm => $realm, _config => $config };
+}
+
+sub BUILD {
+ my ($self, $args) = @_;
$self->_config->{'password_field'} ||= 'password';
$self->_config->{'password_type'} ||= 'clear';
$self->_config->{'password_hash_type'} ||= 'SHA-1';
@@ -29,7 +24,6 @@
if (!grep /$passwordtype/, ('none', 'clear', 'hashed', 'salted_hash', 'crypted', 'self_check')) {
Catalyst::Exception->throw(__PACKAGE__ . " used with unsupported password type: " . $self->_config->{'password_type'});
}
- return $self;
}
sub authenticate {
@@ -92,7 +86,7 @@
}
}
-__PACKAGE__;
+__PACKAGE__->meta->make_immutable;
__END__
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Realm/Progressive.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Realm/Progressive.pm 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Realm/Progressive.pm 2009-06-07 03:26:14 UTC (rev 10465)
@@ -1,10 +1,9 @@
package Catalyst::Authentication::Realm::Progressive;
-
+use Moose;
use Carp;
-use warnings;
-use strict;
+use namespace::autoclean;
-use base 'Catalyst::Authentication::Realm';
+extends 'Catalyst::Authentication::Realm';
=head1 NAME
@@ -148,16 +147,8 @@
## standard realm. So we have to create our realm object, set our name
## and return $self in order to avoid nasty warnings.
-sub new {
- my ($class, $realmname, $config, $app) = @_;
+sub BUILD { }
- my $self = { config => $config };
- bless $self, $class;
-
- $self->name($realmname);
- return $self;
-}
-
=head1 AUTHORS
J. Shirley C<< <jshirley at cpan.org> >>
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Realm.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Realm.pm 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Realm.pm 2009-06-07 03:26:14 UTC (rev 10465)
@@ -1,24 +1,26 @@
package Catalyst::Authentication::Realm;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
+foreach my $attr (qw/store credential name config/) {
+ has $attr => ( is => 'rw' );
+}
-use base qw/Class::Accessor::Fast/;
-
-BEGIN {
- __PACKAGE__->mk_accessors(qw/store credential name config/);
-};
-
## Add use_session config item to realm.
-sub new {
+sub BUILDARGS {
my ($class, $realmname, $config, $app) = @_;
- my $self = { config => $config };
- bless $self, $class;
+ return { __app => $app, name => $realmname, config => $config };
+}
+
+sub BUILD {
+ my ($self, $args) = @_;
- $self->name($realmname);
-
+ my $app = $args->{__app};
+ my $realmname = $self->name;
+ my $config = $self->config;
+
if (!exists($self->config->{'use_session'})) {
if (exists($app->config->{'Plugin::Authentication'}{'use_session'})) {
$self->config->{'use_session'} = $app->config->{'Plugin::Authentication'}{'use_session'};
@@ -138,8 +140,6 @@
$app->log->error("THIS IS DEPRECATED: $credentialclass has no new() method - Attempting to use uninstantiated");
$self->credential($credentialclass);
}
-
- return $self;
}
sub find_user {
@@ -262,7 +262,7 @@
}
-__PACKAGE__;
+__PACKAGE__->meta->make_immutable;
__END__
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Store/Minimal.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Store/Minimal.pm 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Store/Minimal.pm 2009-06-07 03:26:14 UTC (rev 10465)
@@ -1,20 +1,14 @@
package Catalyst::Authentication::Store::Minimal;
-
-use strict;
-use warnings;
-
+use Moose;
use Catalyst::Authentication::User::Hash;
-use Scalar::Util qw( blessed );
-use base qw/Class::Accessor::Fast/;
+use namespace::autoclean;
-BEGIN {
- __PACKAGE__->mk_accessors(qw/userhash/);
-}
+has userhash => ( is => 'rw');
-sub new {
+sub BUILDARGS {
my ( $class, $config, $app, $realm) = @_;
- bless { userhash => $config->{'users'} }, $class;
+ { userhash => $config->{'users'} };
}
sub from_session {
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Store/Null.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Store/Null.pm 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/Store/Null.pm 2009-06-07 03:26:14 UTC (rev 10465)
@@ -1,19 +1,13 @@
package Catalyst::Authentication::Store::Null;
-
-use strict;
-use warnings;
-
+use Moose;
use Catalyst::Authentication::User::Hash;
+use namespace::autoclean;
-use base qw( Class::Accessor::Fast );
+has _config => ( is => 'rw' );
-BEGIN {
- __PACKAGE__->mk_accessors( qw( _config ) );
-}
-
-sub new {
+sub BUILDARGS {
my ( $class, $config, $app, $realm ) = @_;
- bless { _config => $config }, $class;
+ { _config => $config };
}
sub for_session {
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/User/Hash.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/User/Hash.pm 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/User/Hash.pm 2009-06-07 03:26:14 UTC (rev 10465)
@@ -1,14 +1,13 @@
package Catalyst::Authentication::User::Hash;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
+extends qw/Catalyst::Authentication::User/;
-use base qw/Catalyst::Authentication::User/;
+sub BUILD {
+ my ($self, $args) = @_;
-sub new {
- my $class = shift;
-
- bless { ( @_ > 1 ) ? @_ : %{ $_[0] } }, $class;
+ %$self = %$args;
}
sub AUTOLOAD {
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/User.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/User.pm 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Authentication/User.pm 2009-06-07 03:26:14 UTC (rev 10465)
@@ -1,13 +1,9 @@
package Catalyst::Authentication::User;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
-use base qw/Class::Accessor::Fast/;
-
## auth_realm is the realm this user came from.
-BEGIN {
- __PACKAGE__->mk_accessors(qw/auth_realm store/);
-}
+has [qw/auth_realm store/] => ( is => 'rw' );
## THIS IS NOT A COMPLETE CLASS! it is intended to provide base functionality only.
## translation - it won't work if you try to use it directly.
@@ -79,7 +75,7 @@
## return $self->auth_realm->{store};
##}
-__PACKAGE__;
+__PACKAGE__->meta->make_immutable;
__END__
Modified: Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Plugin/Authentication.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Plugin/Authentication.pm 2009-06-07 02:44:21 UTC (rev 10464)
+++ Catalyst-Plugin-Authentication/0.10000/branches/moose/lib/Catalyst/Plugin/Authentication.pm 2009-06-07 03:26:14 UTC (rev 10465)
@@ -1,17 +1,13 @@
package Catalyst::Plugin::Authentication;
-
-use base qw/Class::Accessor::Fast Class::Data::Inheritable/;
-
-__PACKAGE__->mk_accessors(qw/_user/);
-
-use strict;
-use warnings;
-
+use Moose::Role;
use MRO::Compat;
use Tie::RefHash;
use Class::Inspector;
use Catalyst::Authentication::Realm;
+use namespace::autoclean;
+has _user => ( is => 'rw' );
+
our $VERSION = "0.10012";
sub set_authenticated {
More information about the Catalyst-commits
mailing list