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