| 1 | package Catalyst::Authentication::Store::UserXML::Folder; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | our $VERSION = '0.03'; | |||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Catalyst::Authentication::Store::UserXML::User; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Path::Class 'file'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | has 'folder' => (is=>'rw', isa=>'Path::Class::Dir', required => 1); | |||||||||
| 13 | 1 | has 'user_folder_file' => (is=>'rw', isa=>'Str', predicate => 'has_user_folder_file'); | |||||||||
| 14 | |||||||||||
| 15 | 4 | ▶ | sub find_user { | ||||||||
|
Subroutine
find_user: called CC=5 SCAR=19.7
Pod
undocumented
| |||||||||||
| 16 | 4 | my ( $self, $authinfo, $c ) = @_; | |||||||||
| 17 | |||||||||||
| 18 | 4 | my $username = $authinfo->{username}; | |||||||||
| 19 | 4 | ▶ | my $file = ( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | $self->has_user_folder_file | ||||||||||
| 21 | ? file($self->folder, $username, $self->user_folder_file) | ||||||||||
| 22 | : file($self->folder, $username.'.xml') | ||||||||||
| 23 | ); | ||||||||||
| 24 | 4 | ▶ | unless (-r $file) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | ▶ | if (my $fallback = $c->config->{authentication}{userxml}{find_user_fallback}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | return $c->$fallback($authinfo); | |||||||||
| 27 | } | ||||||||||
| 28 | 0 | return undef; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 4 | my $user = Catalyst::Authentication::Store::UserXML::User->new({ | |||||||||
| 32 | xml_filename => $file | ||||||||||
| 33 | }); | ||||||||||
| 34 | |||||||||||
| 35 | 4 | ▶ | die 'username in '.$file.' missmatch' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | if $user->username ne $username; | ||||||||||
| 37 | |||||||||||
| 38 | 4 | return $user; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | ▶ | sub user_supports { | ||||||||
|
Subroutine
user_supports: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 42 | 1 | my $self = shift; | |||||||||
| 43 | 1 | Catalyst::Authentication::Store::UserXML::User->supports(@_); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 1 | ▶ | sub from_session { | ||||||||
|
Subroutine
from_session: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 47 | 1 | my ( $self, $c, $username ) = @_; | |||||||||
| 48 | 1 | $self->find_user( { username => $username }, $c ); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | 1; | |||||||||
| 52 | |||||||||||