1 package Catalyst::Plugin::Authentication::User::Hash;
6 use base qw/Catalyst::Plugin::Authentication::User/;
11 bless { ( @_ > 1 ) ? @_ : %{ $_[0] } }, $class;
16 ( my $key ) = ( our $AUTOLOAD =~ m/([^:]*)$/ );
18 $self->_accessor( $key, @_ );
21 # this class effectively handles any method calls
26 $self->_accessor( "id", @_ );
29 ## deprecated. Let the base class handle this.
32 # $self->_accessor( "store", @_ ) || ref $self;
40 my $arr = $self->{__hash_obj_key_is_array}{$key} = @_ > 1;
41 $self->{$key} = $arr ? [@_] : shift;
44 my $data = $self->{$key};
45 ( $self->{__hash_obj_key_is_array}{$key} || $key =~ /roles/ )
50 ## password portion of this is no longer necessary, but here for backwards compatibility.
53 clear => ["password"],
54 crypted => ["crypted_password"],
55 hashed => [qw/hashed_password hash_algorithm/],
63 my ( $self, @spec ) = @_;
65 my $cursor = \%features;
67 return 1 if @spec == 1 and exists $self->{ $spec[0] };
69 # traverse the feature list,
71 return if ref($cursor) ne "HASH";
72 $cursor = $cursor->{$_};
76 die "bad feature spec: @spec" unless ref $cursor eq "ARRAY";
78 # check that all the keys required for a feature are in here
79 foreach my $key (@$cursor) {
80 return undef unless exists $self->{$key};
93 return $self; # 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>.
129 Create a new object with the key-value-pairs listed in the arg list.
133 Checks for existence of keys that correspond with features.
135 =head2 for_session( )
137 Just returns $self, expecting it to be serializable.
139 =head2 from_session( )
141 Just passes returns the unserialized object, hoping it's intact.
145 Accessor for the key whose name is the method.
149 Accessors that override superclass's dying virtual methods.