prepare for release of C::P::Authentication::Store::Htpasswd
[catagits/Catalyst-Authentication-Store-Htpasswd.git] / lib / Catalyst / Plugin / Authentication / Store / Htpasswd / User.pm
index f018026..42582d6 100644 (file)
@@ -37,7 +37,8 @@ sub check_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 {
@@ -66,11 +67,39 @@ __END__
 Catalyst::Plugin::Authentication::Store::Htpasswd::User - A user object
 representing an entry in an htpasswd file.
 
-=head1 SYNOPSIS
+=head1 DESCRIPTION
 
-       use Catalyst::Plugin::Authentication::Store::Htpasswd::User;
+This object wraps an L<Authen::Htpasswd::User> object. An instance of it will be returned
+by C<< $c->user >> when using L<Catalyst::Plugin::Authentication::Store::Htpasswd>. Methods 
+not defined in this module are passed through to the L<Authen::Htpasswd::User> object. The
+object stringifies to the username.
 
-=head1 DESCRIPTION
+=head1 METHODS
+
+=head2 new($store,$user)
+
+Creates a new object from a store object, normally an instance of 
+L<Catalyst::Plugin::Authentication::Store::Htpasswd::Backend>, and a user object,
+normally an instance of L<Authen::Htpasswd::User>.
+
+=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