Rubric/WebApp/Login/Post.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 95.1% 39 / 41 CC 4 SCAR 5.9
CC
4
Cov
97%
authenticate_login
3.0
get_login_username
2.0
BEGIN
1.0
CRAP 1.8
« Rubric/Entry.pm ↑ Summary Rubric/Entry/Formatter/Nil.pm »
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Rubric::WebApp::Login::Post 0.157;
4 # ABSTRACT: process web login from query parameters
5  
6 2 ▶use parent qw(Rubric::WebApp::Login);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Digest::MD5 qw(md5_hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #pod =head1 DESCRIPTION
11 #pod
12 #pod This module checks the submitted query for information needed to confirm that a
13 #pod user is logged into the Rubric.
14 #pod
15 #pod =head1 METHODS
16 #pod
17 #pod =head2 get_login_username
18 #pod
19 #pod This checks for the username in a current login request. First it checks
20 #pod whether there is a C<current_user> value in this session. If not, it looks for
21 #pod a C<user> query parameter.
22 #pod
23 #pod =cut
24  
25 48 ▶sub get_login_username {
Subroutine get_login_username: called CC=2 SCAR=6.9
Pod documented
26 48 my ($class, $webapp) = @_;
27  
28 48 ▶ $webapp->session->param('current_user') || $webapp->query->param('user');
Branch: 1 branch
BranchTrueFalseTotal
$webapp->session->param("current_user") or $webapp->query->param("user") 15 33 48
29 }
30  
31 #pod =head2 authenticate_login($webapp, $user)
32 #pod
33 #pod This returns true if the username came from the session. Otherwise, it checks
34 #pod for a C<password> query parameter and compares its md5sum against the user's
35 #pod stored password md5sum.
36 #pod
37 #pod =cut
38  
39 17 ▶sub authenticate_login {
Subroutine authenticate_login: called CC=3 SCAR=11.0
Pod documented
40 17 my ($self, $webapp, $user) = @_;
41  
42 17 ▶ return 1 if
Branch: 1 branch
BranchTrueFalseTotal
if $webapp->session->param("current_user") and $webapp->session->param("current_user") eq $user 15 2 17
Condition66%2/3
$webapp->session->param("current_user") and $webapp->session->param("current_user") eq $user
!ll&&!rl&&r
2015
MC/DC50%1/2
$webapp->session->param("current_user") and $webapp->session->param("current_user") eq $user
$webapp->session->param("current_user") $webapp->session->param("current_user") eq $user
Truth table66%2/3
A and B
A= $webapp->session->param("current_user")B= $webapp->session->param("current_user") eq $user
ABresult
0X0
100
111
43 $webapp->session->param('current_user') and
44 $webapp->session->param('current_user') eq $user;
45  
46 2 my $password = $webapp->query->param('password');
47  
48 2 return (md5_hex($password) eq $user->password);
49 }
50  
51 #pod =head2 set_current_user($webapp, $user)
52 #pod
53 #pod This method sets the current user in the session and then calls the superclass
54 #pod C<set_current_user>.
55 #pod
56 #pod =cut
57  
58 17 ▶sub set_current_user {
Subroutine set_current_user: called CC=1 SCAR=0.0
Pod documented
59 17 my ($self, $webapp, $user) = @_;
60  
61 17 $webapp->session->param(current_user => $user->username);
62 17 $self->SUPER::set_current_user($webapp, $user);
63 }
64  
65 2 1;
66  
67 __END__
« Rubric/Entry.pm ↑ Summary Rubric/Entry/Formatter/Nil.pm »