Repositorio/Server/Docker/Helper/Auth/Plain.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 3 SCAR 18.4
CC
3
Cov
0%
login
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 6.3
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4 # vim: set ts=2 sw=2 tw=0:
5 # vim: set expandtab:
6  
7 package Rex::Repositorio::Server::Docker::Helper::Auth::Plain;
8  
9 use Moose;
10 use File::Spec;
11 use JSON::XS;
12 require IO::All;
13  
14 our $VERSION = '1.2.1'; # VERSION
15  
16 has user_path => ( is => 'ro' );
17  
18 sub login {
19 my ( $self, $user, $password ) = @_;
20  
21 my $user_dir = File::Spec->catdir( $self->user_path, $user );
22 my $user_file = File::Spec->catfile( $user_dir, "user.json" );
23  
24 if ( !-f $user_file ) {
25 return 0;
26 }
27  
28 my $user_ref = decode_json( IO::All->new($user_file)->slurp );
29  
30 if ( $user_ref->{password} eq $password ) {
31 return 1;
32 }
33  
34 return 0;
35 }
36  
37 1;