PlugAuth/Plugin/DisableGroup.pm

filter: Statementstmt 51.7% 15 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 2 totaltotal 40.4% 19 / 47 CC 5 SCAR 19.6
CC
5
Cov
41%
init
12.0
check_credentials
12.0
__ANON__
2.0
CRAP 7.1
« PlugAuth/Client.pm ↑ Summary PlugAuth/Role/Auth.pm »
1 package PlugAuth::Plugin::DisableGroup;
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 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: Disable accounts which belong to a group
9 1 our $VERSION = '0.39'; # VERSION
10  
11  
12 1 with 'PlugAuth::Role::Plugin';
13 1 with 'PlugAuth::Role::Auth';
14  
15 sub init
16 0 ▶{
Subroutine init: not called CC=3 SCAR=24.8
Pod undocumented
17 0 my($self) = @_;
18 0 ▶ my $group = $self->{group} = $self->plugin_config->{group} // 'disabled';
Condition0%0/2
$self->plugin_config->{"group"} // "disabled"
l!l
00
MC/DC0%0/1
$self->plugin_config->{"group"} // "disabled"
$self->plugin_config->{"group"}
Truth table0%0/2
A
A= $self->plugin_config->{"group"}
Aresult
11
00
19 0 ▶ if($self->plugin_config->{disable_on_create})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->plugin_config->{"disable_on_create"}) 0 0 0
20 {
21 0 ▶ $self->app->on(create_user => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 0 my($app, $args) = @_;
23 0 my $user = $args->{user};
24 0 $app->authz->update_group($group, join(',', @{ $app->authz->users_in_group($group) }, $user))
25 0 });
26 }
27 }
28  
29 sub check_credentials
30 0 ▶{
Subroutine check_credentials: not called CC=3 SCAR=24.8
Pod undocumented
31 0 my($self, $user, $pass) = @_;
32 0 my $groups = $self->app->authz->groups_for_user($user);
33 0 ▶ return 0 unless $groups;
Branch: 1 branch
BranchTrueFalseTotal
unless $groups 0 0 0
34 0 ▶ return 0 if grep { lc($_) eq $self->{group} } @$groups;
Branch: 1 branch
BranchTrueFalseTotal
if grep {lc $_ eq $self->{"group"};} @$groups 0 0 0
35 0 $self->deligate_check_credentials($user, $pass);
36 }
37  
38 1 1;
39  
40 __END__
« PlugAuth/Client.pm ↑ Summary PlugAuth/Role/Auth.pm »