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, @_ );
22 # this class effectively handles any method calls
27 $self->_accessor( "id", @_ );
30 ## deprecated. Let the base class handle this.
33 # $self->_accessor( "store", @_ ) || ref $self;
41 my $arr = $self->{__hash_obj_key_is_array}{$key} = @_ > 1;
42 $self->{$key} = $arr ? [@_] : shift;
45 my $data = $self->{$key};
46 ( $self->{__hash_obj_key_is_array}{$key} || $key =~ /roles/ )
51 ## password portion of this is no longer necessary, but here for backwards compatibility.
54 clear => ["password"],
55 crypted => ["crypted_password"],
56 hashed => [qw/hashed_password hash_algorithm/],
64 my ( $self, @spec ) = @_;
66 my $cursor = \%features;
68 return 1 if @spec == 1 and exists $self->{ $spec[0] };
70 # traverse the feature list,
72 return if ref($cursor) ne "HASH";
73 $cursor = $cursor->{$_};
77 die "bad feature spec: @spec" unless ref $cursor eq "ARRAY";
79 # check that all the keys required for a feature are in here
80 foreach my $key (@$cursor) {
81 return undef unless exists $self->{$key};
94 return $self; # we serialize the whole user
98 my ( $self, $c, $user ) = @_;
110 Catalyst::Plugin::Authentication::User::Hash - An easy authentication user
111 object based on hashes.
115 use Catalyst::Plugin::Authentication::User::Hash;
117 Catalyst::Plugin::Authentication::User::Hash->new(
118 password => "s3cr3t",
123 This implementation of authentication user handles is supposed to go hand in
124 hand with L<Catalyst::Plugin::Authentication::Store::Minimal>.
132 Create a new object with the key-value-pairs listed in the arg list.
136 Checks for existence of keys that correspond with features.
140 Just returns $self, expecting it to be serializable.
144 Just passes returns the unserialized object, hoping it's intact.
148 Accessor for the key whose name is the method.
154 Accessors that override superclass's dying virtual methods.