dc2bd834ed44c9fcebaaeb53c00e51d0f1691991
[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/file name/) }
10
11 sub new {
12         my ( $class, $name, $file ) = @_;
13
14         bless {
15                 name => $name,
16                 file => $file,
17         }, $class;
18 }
19
20 sub supported_features {
21         return {
22                 password => {
23                         self_check => 1,
24                 }
25         };
26 }
27
28 sub check_password {
29         my ( $self, $password ) = @_;
30
31         return $self->file->htCheckPassword( $self->name, $password );
32 }
33
34 sub roles {
35         my $self = shift;
36         split( ",", $self->info_string );
37 }
38
39 sub info_string {
40         my $self = shift;
41         $self->file->fetchInfo( $self->name );
42 }
43
44 __PACKAGE__;
45
46 __END__
47
48 =pod
49
50 =head1 NAME
51
52 Catalyst::Plugin::Authentication::Store::Htpasswd::User - A user object
53 representing an entry in an htpasswd file.
54
55 =head1 SYNOPSIS
56
57         use Catalyst::Plugin::Authentication::Store::Htpasswd::User;
58
59 =head1 DESCRIPTION
60
61 =cut
62
63