3 package Catalyst::Plugin::Authentication::User::Hash;
4 use base qw/Catalyst::Plugin::Authentication::User/;
12 bless { ( @_ > 1 ) ? @_ : %{ $_[0] } }, $class;
17 ( my $key ) = ( our $AUTOLOAD =~ m/([^:]*)$/ );
19 $self->_accessor( $key, @_ );
24 $self->_accessor( "id", @_ );
27 ## deprecated. Let the base class handle this.
30 # $self->_accessor( "store", @_ ) || ref $self;
38 my $arr = $self->{__hash_obj_key_is_array}{$key} = @_ > 1;
39 $self->{$key} = $arr ? [@_] : shift;
42 my $data = $self->{$key};
43 ( $self->{__hash_obj_key_is_array}{$key} || $key =~ /roles/ )
50 clear => ["password"],
51 crypted => ["crypted_password"],
52 hashed => [qw/hashed_password hash_algorithm/],
60 my ( $self, @spec ) = @_;
62 my $cursor = \%features;
64 return 1 if @spec == 1 and exists $self->{ $spec[0] };
66 # traverse the feature list,
68 return if ref($cursor) ne "HASH";
69 $cursor = $cursor->{$_};
73 die "bad feature spec: @spec" unless ref $cursor eq "ARRAY";
75 # check that all the keys required for a feature are in here
76 foreach my $key (@$cursor) {
77 return undef unless exists $self->{$key};
89 return $self->store && $self->id || $self; # if we have a store and an ID we serialize by ref, otherwise we serialize the whole user
93 my ( $self, $c, $user ) = @_;
105 Catalyst::Plugin::Authentication::User::Hash - An easy authentication user
106 object based on hashes.
110 use Catalyst::Plugin::Authentication::User::Hash;
112 Catalyst::Plugin::Authentication::User::Hash->new(
113 password => "s3cr3t",
118 This implementation of authentication user handles is supposed to go hand in
119 hand with L<Catalyst::Plugin::Authentication::Store::Minimal>.
127 Create a new object with the key-value-pairs listed in the arg list.
131 Checks for existence of keys that correspond with features.
135 Just returns $self, expecting it to be serializable.
139 Just passes returns the unserialized object, hoping it's intact.
143 Accessor for the key whose name is the method.
149 Accessors that override superclass's dying virtual methods.