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/ )
48 ## password portion of this is no longer necessary, but here for backwards compatibility.
51 clear => ["password"],
52 crypted => ["crypted_password"],
53 hashed => [qw/hashed_password hash_algorithm/],
61 my ( $self, @spec ) = @_;
63 my $cursor = \%features;
65 return 1 if @spec == 1 and exists $self->{ $spec[0] };
67 # traverse the feature list,
69 return if ref($cursor) ne "HASH";
70 $cursor = $cursor->{$_};
74 die "bad feature spec: @spec" unless ref $cursor eq "ARRAY";
76 # check that all the keys required for a feature are in here
77 foreach my $key (@$cursor) {
78 return undef unless exists $self->{$key};
90 return $self->store && $self->id || $self; # if we have a store and an ID we serialize by ref, otherwise we serialize the whole user
94 my ( $self, $c, $user ) = @_;
106 Catalyst::Plugin::Authentication::User::Hash - An easy authentication user
107 object based on hashes.
111 use Catalyst::Plugin::Authentication::User::Hash;
113 Catalyst::Plugin::Authentication::User::Hash->new(
114 password => "s3cr3t",
119 This implementation of authentication user handles is supposed to go hand in
120 hand with L<Catalyst::Plugin::Authentication::Store::Minimal>.
128 Create a new object with the key-value-pairs listed in the arg list.
132 Checks for existence of keys that correspond with features.
136 Just returns $self, expecting it to be serializable.
140 Just passes returns the unserialized object, hoping it's intact.
144 Accessor for the key whose name is the method.
150 Accessors that override superclass's dying virtual methods.