| 1 | package Nitesi::Account::Provider::Test; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Nitesi::Core::Types; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | with 'Nitesi::Core::Role::Account'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | Nitesi::Account::Provider::Test - Test account provider for Nitesi Shop Machine | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =cut | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | has users => ( | |||||||||||||||||||||||||||
| 15 | is => 'rw', | ||||||||||||||||||||||||||||
| 16 | isa => HashRef, | ||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 METHODS | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head2 login | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | Login method. | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 4 | ▶ | sub login { | ||||||||||||||||||||||||||
|
Subroutine
login: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 4 | my ($self, %args) = @_; | |||||||||||||||||||||||||||
| 29 | 4 | my ($users, $username); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 4 | for (qw/username password/) { | |||||||||||||||||||||||||||
| 32 | 8 | ▶ | return unless exists $args{$_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | $users = $self->users; | |||||||||||||||||||||||||||
| 36 | 4 | $username = $args{username}; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | ▶ | if (exists $users->{$username} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $users->{$username} and $args{"password"} eq $users->{$username}{"password"}
MC/DC100%2/2
exists $users->{$username} and $args{"password"} eq $users->{$username}{"password"}
exists $users->{$username}
$args{"password"} eq $users->{$username}{"password"}
Truth table100%3/3
A and B
A= exists $users->{$username}B= $args{"password"} eq $users->{$username}{"password"}
| |||||||||||||||||||||||||||||
| 39 | && $args{password} eq $users->{$username}->{password}) { | ||||||||||||||||||||||||||||
| 40 | 2 | ▶ | my $last_login = $users->{$username}->{last_login} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$users->{$username}{'last_login'} || 0
MC/DC100%1/1
$users->{$username}{'last_login'} || 0
$users->{$username}{'last_login'}
Truth table100%2/2
A
A= $users->{$username}{'last_login'}
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 2 | $users->{$username}->{last_login} = time; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | return {uid => $users->{$username}->{uid}, | ||||||||||||||||||||||||||||
| 45 | username => $args{username}, | ||||||||||||||||||||||||||||
| 46 | permissions => $users->{$args{username}}->{permissions}, | ||||||||||||||||||||||||||||
| 47 | 2 | last_login => $last_login, | |||||||||||||||||||||||||||
| 48 | }; | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | L<MooX::Types::MooseLike> for more available types | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | Stefan Hornburg (Racke), <racke@linuxia.de> | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Copyright 2012-2013 Stefan Hornburg (Racke) <racke@linuxia.de>. | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 68 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||
| 69 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1 | 1; | |||||||||||||||||||||||||||