Catalyst-Plugin-Authentication
view release on metacpan or search on metacpan
lib/Catalyst/Authentication/User.pm view on Meta::CPAN
## chances are you want to override this.
sub id { shift->get('id'); }
## this relies on 'supported_features' being implemented by the subclass..
## but it is not an error if it is not. it just means you support nothing.
## nihilist user objects are welcome here.
sub supports {
my ( $self, @spec ) = @_;
my $cursor = undef;
if ($self->can('supported_features')) {
$cursor = $self->supported_features;
# traverse the feature list,
for (@spec) {
#die "bad feature spec: @spec" if ref($cursor) ne "HASH";
return if ref($cursor) ne "HASH";
$cursor = $cursor->{$_};
}
}
return $cursor;
}
## REQUIRED.
## get should return the value of the field specified as it's single argument from the underlying
## user object. This is here to provide a simple, standard way of accessing individual elements of a user
## object - ensuring no overlap between C::P::A::User methods and actual fieldnames.
## this is not the most effecient method, since it uses introspection. If you have an underlying object
## you most likely want to write this yourself.
sub get {
my ($self, $field) = @_;
lib/Catalyst/Authentication/User/Hash.pm view on Meta::CPAN
hashed => [qw/hashed_password hash_algorithm/],
self_check => undef,
},
roles => ["roles"],
session => 1,
);
sub supports {
my ( $self, @spec ) = @_;
my $cursor = \%features;
return 1 if @spec == 1 and exists $self->{ $spec[0] };
# traverse the feature list,
for (@spec) {
return if ref($cursor) ne "HASH";
$cursor = $cursor->{$_};
}
if ( ref $cursor ) {
die "bad feature spec: @spec" unless ref $cursor eq "ARRAY";
# check that all the keys required for a feature are in here
foreach my $key (@$cursor) {
return undef unless exists $self->{$key};
}
return 1;
}
else {
return $cursor;
}
}
sub for_session {
my $self = shift;
return $self; # we serialize the whole user
}
sub from_session {
( run in 0.788 second using v1.01-cache-2.11-cpan-4d50c553e7e )