Update htpasswd store for registered stores
[catagits/Catalyst-Authentication-Store-Htpasswd.git] / lib / Catalyst / Plugin / Authentication / Store / Htpasswd / User.pm
CommitLineData
e8a7c384 1#!/usr/bin/perl
2
3package Catalyst::Plugin::Authentication::Store::Htpasswd::User;
4use base qw/Catalyst::Plugin::Authentication::User Class::Accessor::Fast/;
5
6use strict;
7use warnings;
8
039544ff 9BEGIN { __PACKAGE__->mk_accessors(qw/user store/) }
e8a7c384 10
47fb088e 11use overload '""' => sub { shift->user->username };
12
e8a7c384 13sub new {
039544ff 14 my ( $class, $store, $user ) = @_;
e8a7c384 15
039544ff 16 bless { store => $store, user => $user }, $class;
e8a7c384 17}
18
19sub supported_features {
20 return {
21 password => {
22 self_check => 1,
47fb088e 23 },
24 session => 1
e8a7c384 25 };
26}
27
28sub check_password {
29 my ( $self, $password ) = @_;
30
3e0bbcff 31 return $self->user->check_password( $password );
e8a7c384 32}
33
34sub roles {
35 my $self = shift;
3e0bbcff 36 split( ",", $self->user->extra_info );
e8a7c384 37}
38
47fb088e 39sub for_session {
40 my $self = shift;
ec31fe73 41 return $self->user->username;
47fb088e 42}
43
039544ff 44sub AUTOLOAD {
45 my $self = shift;
46
47 ( my $method ) = ( our $AUTOLOAD =~ /([^:]+)$/ );
48
49 return if $method eq "DESTROY";
50
51 $self->user->$method;
47fb088e 52}
53
e8a7c384 54__PACKAGE__;
55
56__END__
57
58=pod
59
60=head1 NAME
61
62Catalyst::Plugin::Authentication::Store::Htpasswd::User - A user object
63representing an entry in an htpasswd file.
64
65=head1 SYNOPSIS
66
67 use Catalyst::Plugin::Authentication::Store::Htpasswd::User;
68
69=head1 DESCRIPTION
70
71=cut
72
73