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", @_ );
37 my $arr = $self->{__hash_obj_key_is_array}{$key} = @_ > 1;
38 $self->{$key} = $arr ? [@_] : shift;
41 my $data = $self->{$key};
42 ( $self->{__hash_obj_key_is_array}{$key} || $key =~ /roles/ )
49 clear => ["password"],
50 crypted => ["crypted_password"],
51 hashed => [qw/hashed_password hash_algorithm/],
59 my ( $self, @spec ) = @_;
61 my $cursor = \%features;
63 return 1 if @spec == 1 and exists $self->{ $spec[0] };
65 # traverse the feature list,
67 return if ref($cursor) ne "HASH";
68 $cursor = $cursor->{$_};
72 die "bad feature spec: @spec" unless ref $cursor eq "ARRAY";
74 # check that all the keys required for a feature are in here
75 foreach my $key (@$cursor) {
76 return undef unless exists $self->{$key};
88 return $self; # let's hope we're serialization happy
92 my ( $self, $c, $user ) = @_;
104 Catalyst::Plugin::Authentication::User::Hash - An easy authentication user
105 object based on hashes.
109 use Catalyst::Plugin::Authentication::User::Hash;
111 Catalyst::Plugin::Authentication::User::Hash->new(
112 password => "s3cr3t",
117 This implementation of authentication user handles is supposed to go hand in
118 hand with L<Catalyst::Plugin::Authentication::Store::Minimal>.
126 Create a new object with the key-value-pairs listed in the arg list.
130 Checks for existence of keys that correspond with features.
134 Just returns $self, expecting it to be serializable.
138 Just passes returns the unserialized object, hoping it's intact.
142 Accessor for the key whose name is the method.
148 Accessors that override superclass's dying virtual methods.