blib/lib/Lemonldap/NG/Portal/Plugins/PublicPages.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 37 CC 3 SCAR 19.5
CC
3
Cov
0%
run
12.0
init
2.0
BEGIN
2.0
CRAP 7.0
1 package Lemonldap::NG::Portal::Plugins::PublicPages;
2  
3 use strict;
4 use Mouse;
5  
6 extends 'Lemonldap::NG::Portal::Main::Plugin';
7  
8 our $VERSION = '2.23.0';
9  
10 sub init {
11 my ($self) = @_;
12 $self->addAuthRoute( public => { ':tpl' => 'run' }, ['GET'] )
13 ->addUnauthRoute( public => { ':tpl' => 'run' }, ['GET'] );
14  
15 return 1;
16 }
17  
18 sub run {
19 my ( $self, $req ) = @_;
20 my $tpl = $req->param('tpl');
21  
22 unless ( $tpl =~ /^[\w\.\-]+$/ ) {
23 $self->userLogger->error("Bad public path $tpl");
24 return $self->p->sendError( $req, 'File not found', 404 );
25 }
26  
27 $tpl = "public/$tpl";
28 my $path =
29 $self->conf->{templateDir} . '/'
30 . $self->conf->{portalSkin}
31 . "/$tpl.tpl";
32  
33 unless ( -e $path ) {
34 $self->userLogger->warn("File not found: $path");
35 return $self->p->sendError( $req, 'File not found', 404 );
36 }
37 return $self->p->sendHtml( $req, $tpl );
38 }
39  
40 1;
41  
42 __END__