| 1 | package Yote::Server::App; | ||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Yote::Server; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Digest::MD5; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use base 'Yote::ServerObj'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub _acct_class { "Yote::Server::Acct" } | ||||||||||||||||||||||||||
|
Subroutine
_acct_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||
| 15 | # Override and call _create_account | ||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | sub create_account { | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | die "May not create account via website"; | ||||||||||||||||||||||||||
|
Subroutine
create_account: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub _create_account { | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | my( $self, $un, $pw, $class_override ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_create_account: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 23 | 0 | my $accts = $self->get__accts({}); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if( $accts->{lc($un)} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | $self->_err( "Unable to create account" ); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my $acct = $self->{STORE}->newobj( { user => $un }, $class_override || $self->_acct_class ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$class_override || $self->_acct_class
MC/DC0%0/2
$class_override || $self->_acct_class
$class_override
$self->_acct_class
Truth table0%0/3
A || B
A= $class_overrideB= $self->_acct_class
| |||||||||||||||||||||||||||||
| 30 | 0 | $acct->set__password_hash( crypt( $pw, length( $pw ) . Digest::MD5::md5_hex($acct->{ID} ) ) ); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # TODO - create an email infrastructure for account validation | ||||||||||||||||||||||||||||
| 33 | 0 | $acct->set_app( $self ); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | $accts->{lc($un)} = $acct; | |||||||||||||||||||||||||||
| 36 | 0 | $acct; | |||||||||||||||||||||||||||
| 37 | } #_create_account | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sub logout { | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
logout: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | my $root = $self->{SESSION}{SERVER_ROOT}; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | $root->_destroy_session( $self->{SESSION}->get__token ) if $root; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | delete $self->{SESSION}; | |||||||||||||||||||||||||||
| 44 | 0 | 1; | |||||||||||||||||||||||||||
| 45 | } #logout | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | sub login { | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my( $self, $un, $pw ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
login: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # returns account, cookie. only way to get account object | ||||||||||||||||||||||||||||
| 51 | 0 | my $acct = $self->get__accts({})->{lc($un)}; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # doing it like this so a failed attempt has about the same amount of time | ||||||||||||||||||||||||||||
| 54 | # as an attempt against a nonexistant account. maybe random microsleep? | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $pwh = crypt( $pw, length( $pw ) . Digest::MD5::md5_hex($acct ? $acct->{ID} : $self->{ID} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if( $acct && $pwh eq $acct->get__password_hash ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$acct and $pwh eq $acct->get__password_hash
MC/DC0%0/2
$acct and $pwh eq $acct->get__password_hash
$acct
$pwh eq $acct->get__password_hash
Truth table0%0/3
A and B
A= $acctB= $pwh eq $acct->get__password_hash
| |||||||||||||||||||||||||||||
| 57 | # this and Yote::ServerRoot::fetch_app are the only ways to expose the account obj | ||||||||||||||||||||||||||||
| 58 | # to the UI. If the UI calls for an acct object it wasn't exposed to, Yote::Server | ||||||||||||||||||||||||||||
| 59 | # won't allow it. fetch_app only calls it if the correct cookie token is passed in | ||||||||||||||||||||||||||||
| 60 | 0 | $self->{SESSION}->set_acct( $acct ); | |||||||||||||||||||||||||||
| 61 | 0 | $acct->_onLogin; | |||||||||||||||||||||||||||
| 62 | 0 | return $acct; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | 0 | $self->_err( "Incorrect login" ); | |||||||||||||||||||||||||||
| 65 | } #login | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 1 | 1; | |||||||||||||||||||||||||||