Commit | Line | Data |
e8a7c384 |
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 | |
039544ff |
9 | BEGIN { __PACKAGE__->mk_accessors(qw/user store/) } |
e8a7c384 |
10 | |
7efcea1c |
11 | use overload '""' => sub { shift->id }, fallback => 1; |
47fb088e |
12 | |
e8a7c384 |
13 | sub new { |
039544ff |
14 | my ( $class, $store, $user ) = @_; |
e8a7c384 |
15 | |
039544ff |
16 | bless { store => $store, user => $user }, $class; |
e8a7c384 |
17 | } |
18 | |
7efcea1c |
19 | sub id { |
20 | my $self = shift; |
21 | return $self->user->username; |
22 | } |
23 | |
e8a7c384 |
24 | sub supported_features { |
25 | return { |
26 | password => { |
27 | self_check => 1, |
47fb088e |
28 | }, |
29 | session => 1 |
e8a7c384 |
30 | }; |
31 | } |
32 | |
33 | sub check_password { |
34 | my ( $self, $password ) = @_; |
3e0bbcff |
35 | return $self->user->check_password( $password ); |
e8a7c384 |
36 | } |
37 | |
38 | sub roles { |
39 | my $self = shift; |
7efcea1c |
40 | split( /,/, $self->user->extra_info ); |
e8a7c384 |
41 | } |
42 | |
47fb088e |
43 | sub for_session { |
44 | my $self = shift; |
7efcea1c |
45 | return $self->id; |
47fb088e |
46 | } |
47 | |
039544ff |
48 | sub AUTOLOAD { |
49 | my $self = shift; |
50 | |
51 | ( my $method ) = ( our $AUTOLOAD =~ /([^:]+)$/ ); |
52 | |
53 | return if $method eq "DESTROY"; |
54 | |
55 | $self->user->$method; |
47fb088e |
56 | } |
57 | |
e8a7c384 |
58 | __PACKAGE__; |
59 | |
60 | __END__ |
61 | |
62 | =pod |
63 | |
64 | =head1 NAME |
65 | |
66 | Catalyst::Plugin::Authentication::Store::Htpasswd::User - A user object |
67 | representing an entry in an htpasswd file. |
68 | |
69 | =head1 SYNOPSIS |
70 | |
71 | use Catalyst::Plugin::Authentication::Store::Htpasswd::User; |
72 | |
73 | =head1 DESCRIPTION |
74 | |
75 | =cut |
76 | |
77 | |