#!/usr/bin/perl
package Catalyst::Authentication::Store::Htpasswd::User;
+# ABSTRACT: A user object representing an entry in an htpasswd file.
+
use base qw/Catalyst::Authentication::User Class::Accessor::Fast/;
use strict;
use warnings;
-BEGIN { __PACKAGE__->mk_accessors(qw/user store/) }
+our $VERSION = '1.006';
+
+BEGIN { __PACKAGE__->mk_accessors(qw/_user _store/) }
use overload '""' => sub { shift->id }, fallback => 1;
return unless $user;
- bless { store => $store, user => $user }, $class;
+ bless { _store => $store, _user => $user }, $class;
}
sub id {
my $self = shift;
- return $self->user->username;
+ return $self->_user->username;
}
sub supported_features {
sub check_password {
my ( $self, $password ) = @_;
- return $self->user->check_password( $password );
+ return $self->_user->check_password( $password );
}
sub roles {
my $self = shift;
- my $field = $self->user->extra_info->[0];
+ my $field = $self->_user->extra_info->[0];
return defined $field ? split /,/, $field : ();
}
-sub for_session {
- my $self = shift;
- return $self->id;
-}
+*for_session = \&id;
+
+*get_object = \&_user;
sub AUTOLOAD {
my $self = shift;
-
+
( my $method ) = ( our $AUTOLOAD =~ /([^:]+)$/ );
return if $method eq "DESTROY";
-
- $self->user->$method;
+
+ $self->_user->$method;
}
1;
=pod
-=head1 NAME
-
-Catalyst::Authentication::Store::Htpasswd::User - A user object
-representing an entry in an htpasswd file.
-
=head1 DESCRIPTION
This object wraps an L<Authen::Htpasswd::User> object. An instance of it will be returned
-by C<< $c->user >> when using L<Catalyst::Authentication::Store::Htpasswd>. Methods
+by C<< $c->user >> when using L<Catalyst::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.
=head2 new($store,$user)
-Creates a new object from a store object, normally an instance of
-L<Catalyst::Authentication::Store::Htpasswd::Backend>, and a user object,
+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 data about which featurs this user module supports.
-=head1 AUTHORS
-
-Yuval Kogman C<nothingmuch@woobling.org>
-
-David Kamholz C<dkamholz@cpan.org>
-
-Tomas Doran C<bobtfish@bobtfish.net>
+=head2 get_object
-=head1 COPYRIGHT & LICENSE
-
- 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.
+Returns the underlieing L<Authen::Htpasswd::User> object for this user
=cut
-
-