« blib/lib/Lemonldap/NG/Portal/Lib/Captcha.pm
↑ Summary
blib/lib/Lemonldap/NG/Portal/2F/WebAuthn.pm »
| 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__ |