blib/lib/Eidolon/Driver/User/Basic.pm

filter: Statementstmt 39.2% 11 / 28 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 3 / 6 Podpod 100% 3 / 3 totaltotal 40.4% 17 / 42 CC 2 SCAR 10.0
CC
2
Cov
35%
authorized
6.0
authorize
2.0
unauthorize
2.0
CRAP 2.7
↑ Summary
1 package Eidolon::Driver::User::Basic;
2 # ==============================================================================
3 #
4 # Eidolon
5 # Copyright (c) 2009, Atma 7
6 # ---
7 # Eidolon/Driver/User/Basic.pm - basic user driver
8 #
9 # ==============================================================================
10  
11 1 ▶use base qw/Eidolon::Driver::User/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 our $VERSION = "0.02"; # 2009-04-06 02:04:33
16  
17 # ------------------------------------------------------------------------------
18 # authorize($login)
19 # authorize user
20 # ------------------------------------------------------------------------------
21 sub authorize
22 0 ▶{
Subroutine authorize: not called CC=1 SCAR=6.9
Pod documented
23 0 my ($self, $login, $r);
24  
25 0 ($self, $login) = @_;
26 0 $r = Eidolon::Core::Registry->get_instance;
27  
28 0 $r->cgi->start_session;
29 0 $r->cgi->set_session("login", $login);
30 0 $r->cgi->set_session("ip", $self->ip);
31  
32 0 __PACKAGE__->mk_accessors("login");
33 0 $self->login( $login );
34 }
35  
36 # ------------------------------------------------------------------------------
37 # unauthorize()
38 # unauthorize user
39 # ------------------------------------------------------------------------------
40 sub unauthorize
41 0 ▶{
Subroutine unauthorize: not called CC=1 SCAR=6.9
Pod documented
42 0 my ($self, $r);
43  
44 0 $self = shift;
45 0 $r = Eidolon::Core::Reigstry->get_instance;
46  
47 0 $r->cgi->destroy_session;
48 0 $self->login( undef );
49 }
50  
51 # ------------------------------------------------------------------------------
52 # $ authorized()
53 # check if user is authorized
54 # ------------------------------------------------------------------------------
55 sub authorized
56 0 ▶{
Subroutine authorized: not called CC=2 SCAR=17.9
Pod documented
57 0 my ($self, $r);
58  
59 0 $self = shift;
60 0 $r = Eidolon::Core::Registry->get_instance;
61  
62 0 ▶ return $r->cgi->get_session("login") && ($r->cgi->get_session("ip") eq $self->ip);
Condition0%0/3
$r->cgi->get_session('login') && $r->cgi->get_session('ip') eq $self->ip
!ll&&!rl&&r
000
MC/DC0%0/2
$r->cgi->get_session('login') && $r->cgi->get_session('ip') eq $self->ip
$r->cgi->get_session('login') $r->cgi->get_session('ip') eq $self->ip
Truth table0%0/3
A && B
A= $r->cgi->get_session('login')B= $r->cgi->get_session('ip') eq $self->ip
ABresult
0X0
100
111
63 }
64  
65 1 1;
66  
67 __END__
↑ Summary