r10518@t0mlaptop (orig r10517): t0m | 2009-06-12 11:27:58 +0100
[catagits/Catalyst-Plugin-Authentication.git] / lib / Catalyst / Authentication / Credential / Password.pm
index b588c7f..8010fe3 100644 (file)
@@ -1,25 +1,22 @@
 package Catalyst::Authentication::Credential::Password;
-
-use strict;
-use warnings;
-
-use base qw/Class::Accessor::Fast/;
+use Moose;
+use namespace::autoclean;
 
 use Scalar::Util        ();
 use Catalyst::Exception ();
 use Digest              ();
 
-__PACKAGE__->mk_accessors(qw/_config realm/);
+has [qw/_config realm/] => ( is => 'rw' );
 
-sub new {
+sub BUILDARGS {
     my ($class, $config, $app, $realm) = @_;
 
     # Note _config is horrible back compat hackery!
-    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';
@@ -28,7 +25,6 @@ sub new {
     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 {
@@ -94,7 +90,7 @@ sub check_password {
     }
 }
 
-__PACKAGE__;
+__PACKAGE__->meta->make_immutable;
 
 __END__