1 package Catalyst::Plugin::Authentication::User::Hash;
2 use base qw/Catalyst::Plugin::Authentication::User/;
10 bless { ( @_ > 1 ) ? @_ : %{ $_[0] } }, $class;
15 ( my $key ) = ( our $AUTOLOAD =~ m/([^:]*)$/ );
17 $self->_accessor( $key, @_ );
20 # this class effectively handles any method calls
25 $self->_accessor( "id", @_ );
28 ## deprecated. Let the base class handle this.
31 # $self->_accessor( "store", @_ ) || ref $self;
39 my $arr = $self->{__hash_obj_key_is_array}{$key} = @_ > 1;
40 $self->{$key} = $arr ? [@_] : shift;
43 my $data = $self->{$key};
44 ( $self->{__hash_obj_key_is_array}{$key} || $key =~ /roles/ )
49 ## password portion of this is no longer necessary, but here for backwards compatibility.
52 clear => ["password"],
53 crypted => ["crypted_password"],
54 hashed => [qw/hashed_password hash_algorithm/],
62 my ( $self, @spec ) = @_;
64 my $cursor = \%features;
66 return 1 if @spec == 1 and exists $self->{ $spec[0] };
68 # traverse the feature list,
70 return if ref($cursor) ne "HASH";
71 $cursor = $cursor->{$_};
75 die "bad feature spec: @spec" unless ref $cursor eq "ARRAY";
77 # check that all the keys required for a feature are in here
78 foreach my $key (@$cursor) {
79 return undef unless exists $self->{$key};
92 return $self; # we serialize the whole user
96 my ( $self, $c, $user ) = @_;
108 Catalyst::Plugin::Authentication::User::Hash - An easy authentication user
109 object based on hashes.
113 use Catalyst::Plugin::Authentication::User::Hash;
115 Catalyst::Plugin::Authentication::User::Hash->new(
116 password => "s3cr3t",
121 This implementation of authentication user handles is supposed to go hand in
122 hand with L<Catalyst::Plugin::Authentication::Store::Minimal>.
130 Create a new object with the key-value-pairs listed in the arg list.
134 Checks for existence of keys that correspond with features.
138 Just returns $self, expecting it to be serializable.
142 Just passes returns the unserialized object, hoping it's intact.
146 Accessor for the key whose name is the method.
152 Accessors that override superclass's dying virtual methods.