| 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
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
$webapp->session->param("current_user") and $webapp->session->param("current_user") eq $user
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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||