| 1 | package Catalyst::Authentication::Store::Model::KiokuDB; | ||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Catalyst::Authentication::Store::Model::KiokuDB::UserWrapper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | sub BUILDARGS { | ||||||||
|
Subroutine
BUILDARGS: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 11 | 1 | my ($class, $conf, $app, $realm) = @_; | |||||||||
| 12 | |||||||||||
| 13 | return { | ||||||||||
| 14 | 1 | app => $app, | |||||||||
| 15 | realm => $realm, | ||||||||||
| 16 | %$conf, | ||||||||||
| 17 | } | ||||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 1 | has realm => ( | |||||||||
| 21 | is => "ro", | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | 1 | has model_name => ( | |||||||||
| 25 | isa => "Str", | ||||||||||
| 26 | is => "ro", | ||||||||||
| 27 | required => 1, | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | 1 | has user_prefix => ( | |||||||||
| 31 | is => 'ro', | ||||||||||
| 32 | isa => 'Str', | ||||||||||
| 33 | default => 'user:', | ||||||||||
| 34 | ); | ||||||||||
| 35 | |||||||||||
| 36 | 4 | ▶ | sub get_model { | ||||||||
|
Subroutine
get_model: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 37 | 4 | my ( $self, $c ) = @_; | |||||||||
| 38 | |||||||||||
| 39 | 4 | $c->model($self->model_name); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 2 | ▶ | sub wrap { | ||||||||
|
Subroutine
wrap: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 43 | 2 | my ( $self, $c, $user ) = @_; | |||||||||
| 44 | |||||||||||
| 45 | 2 | ▶ | croak "No user object" unless ref $user; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | |||||||||||
| 47 | 2 | return Catalyst::Authentication::Store::Model::KiokuDB::UserWrapper->new( | |||||||||
| 48 | directory => $self->get_model($c)->directory, | ||||||||||
| 49 | user_object => $user, | ||||||||||
| 50 | ); | ||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub from_session { | ||||||||
|
Subroutine
from_session: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 54 | 0 | my ( $self, $c, $id ) = @_; | |||||||||
| 55 | |||||||||||
| 56 | 0 | my $user = $self->get_model($c)->lookup($id); | |||||||||
| 57 | |||||||||||
| 58 | 0 | $self->wrap($c, $user); | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 2 | ▶ | sub find_user { | ||||||||
|
Subroutine
find_user: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||
| 62 | 2 | my ( $self, $userinfo, $c ) = @_; | |||||||||
| 63 | |||||||||||
| 64 | 2 | my $model = $self->get_model($c); | |||||||||
| 65 | |||||||||||
| 66 | 2 | ▶ | my $user = $model->can("find_user") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | ? $model->find_user($userinfo) | ||||||||||
| 68 | : $self->find_user_by_id($userinfo, $model); | ||||||||||
| 69 | |||||||||||
| 70 | 2 | ▶ | if ( $user ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | 2 | return $self->wrap($c, $user); | |||||||||
| 72 | } else { | ||||||||||
| 73 | 0 | return; | |||||||||
| 74 | } | ||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 2 | ▶ | sub find_user_by_id { | ||||||||
|
Subroutine
find_user_by_id: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 78 | 2 | my ( $self, $userinfo, $model ) = @_; | |||||||||
| 79 | |||||||||||
| 80 | 2 | my $id = $userinfo->{id}; | |||||||||
| 81 | |||||||||||
| 82 | $id = $userinfo->{username} | ||||||||||
| 83 | 2 | ▶ | unless defined $id; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | |||||||||||
| 85 | 2 | ▶ | croak "No user ID specified" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 86 | unless defined $id; | ||||||||||
| 87 | |||||||||||
| 88 | # KiokuX::User convention... FIXME also support ->search? | ||||||||||
| 89 | 2 | $model->lookup($self->user_prefix . $id); | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 93 | |||||||||||
| 94 | 1 | __PACKAGE__ | |||||||||
| 95 | |||||||||||
| 96 | __END__ | ||||||||||