X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FAuthentication%2FStore%2FHtpasswd%2FUser.pm;h=42582d6428c954f5637925c9e33c7e37a34a2472;hb=cedb9fb4ae54e24ead346e95e1a9f574ea543eb8;hp=ce4388a9d0e1f078da76d5a1296c89c5c94bf8dc;hpb=039544ff7e03ea53d05dab5e7dcf6cdb3122f886;p=catagits%2FCatalyst-Authentication-Store-Htpasswd.git diff --git a/lib/Catalyst/Plugin/Authentication/Store/Htpasswd/User.pm b/lib/Catalyst/Plugin/Authentication/Store/Htpasswd/User.pm index ce4388a..42582d6 100644 --- a/lib/Catalyst/Plugin/Authentication/Store/Htpasswd/User.pm +++ b/lib/Catalyst/Plugin/Authentication/Store/Htpasswd/User.pm @@ -8,7 +8,7 @@ use warnings; BEGIN { __PACKAGE__->mk_accessors(qw/user store/) } -use overload '""' => sub { shift->user->username }; +use overload '""' => sub { shift->id }, fallback => 1; sub new { my ( $class, $store, $user ) = @_; @@ -16,6 +16,11 @@ sub new { bless { store => $store, user => $user }, $class; } +sub id { + my $self = shift; + return $self->user->username; +} + sub supported_features { return { password => { @@ -27,18 +32,18 @@ sub supported_features { sub check_password { my ( $self, $password ) = @_; - return $self->user->check_password( $password ); } sub roles { my $self = shift; - split( ",", $self->user->extra_info ); + my $field = $self->user->extra_info->[0]; + return defined $field ? split /,/, $field : (); } sub for_session { my $self = shift; - return $self->user->username; + return $self->id; } sub AUTOLOAD { @@ -62,11 +67,39 @@ __END__ Catalyst::Plugin::Authentication::Store::Htpasswd::User - A user object representing an entry in an htpasswd file. -=head1 SYNOPSIS +=head1 DESCRIPTION + +This object wraps an L object. An instance of it will be returned +by C<< $c->user >> when using L. Methods +not defined in this module are passed through to the L object. The +object stringifies to the username. - use Catalyst::Plugin::Authentication::Store::Htpasswd::User; +=head1 METHODS -=head1 DESCRIPTION +=head2 new($store,$user) + +Creates a new object from a store object, normally an instance of +L, and a user object, +normally an instance of L. + +=head2 id + +Returns the username. + +=head2 check_password($password) + +Returns whether the password is valid. + +=head2 roles + +Returns an array of roles, which is extracted from a comma-separated list in the +third field of the htpasswd file. + +=head1 COPYRIGHT & LICNESE + + Copyright (c) 2005 the aforementioned authors. All rights + reserved. This program is free software; you can redistribute + it and/or modify it under the same terms as Perl itself. =cut