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};
93 return $self->store && $self->id || $self; # if we have a store and an ID we serialize by ref, otherwise we serialize the whole user
97 my ( $self, $c, $user ) = @_;
109 Catalyst::Plugin::Authentication::User::Hash - An easy authentication user
110 object based on hashes.
114 use Catalyst::Plugin::Authentication::User::Hash;
116 Catalyst::Plugin::Authentication::User::Hash->new(
117 password => "s3cr3t",
122 This implementation of authentication user handles is supposed to go hand in
123 hand with L<Catalyst::Plugin::Authentication::Store::Minimal>.
131 Create a new object with the key-value-pairs listed in the arg list.
135 Checks for existence of keys that correspond with features.
139 Just returns $self, expecting it to be serializable.
143 Just passes returns the unserialized object, hoping it's intact.
147 Accessor for the key whose name is the method.
153 Accessors that override superclass's dying virtual methods.