diff --git a/lemonldap-ng-common/lemonldap-ng.ini b/lemonldap-ng-common/lemonldap-ng.ini index 8e096d165..41d084583 100644 --- a/lemonldap-ng-common/lemonldap-ng.ini +++ b/lemonldap-ng-common/lemonldap-ng.ini @@ -118,6 +118,11 @@ localStorageOptions={ \ # Old menu HTML code # Enable it if you use old templates ;useOldMenuItems=1 +# Override error codes +;error_0 = You are well authenticated! +# Custom template parameters +# For example to use +;tpl_myparam = test # LOG # By default, all is logged in Apache file. To log user actions by diff --git a/lemonldap-ng-portal/example/mail.pl b/lemonldap-ng-portal/example/mail.pl index 19fade0cb..da291b4ab 100755 --- a/lemonldap-ng-portal/example/mail.pl +++ b/lemonldap-ng-portal/example/mail.pl @@ -115,6 +115,13 @@ if ( $portal->{mail_token} ); } +# Custom template parameters +if ( my $customParams = $portal->getCustomTemplateParameters() ) { + foreach ( keys %$customParams ) { + $template->param( $_, $customParams->{$_} ); + } +} + print $portal->header('text/html; charset=utf8'); print $template->output; diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Display.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Display.pm index f7c277942..83b13f181 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Display.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Display.pm @@ -325,6 +325,11 @@ sub display { ANTIFRAME => $self->{portalAntiFrame}, ); + ## Custom template params + if ( my $customParams = $self->getCustomTemplateParameters() ) { + %templateParams = ( %templateParams, %$customParams ); + } + return ( "$skin_dir/$skin/$skinfile", %templateParams ); } diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm index 8dc4c5cb2..33156763f 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm @@ -2422,8 +2422,7 @@ sub issuerForAuthUser { unless ( $self->safe->reval($rule) ) { $self->lmLog( "User $user was not allowed to use IssuerDB $issuerDBtype", - 'warn' - ); + 'warn' ); return PE_OK; } @@ -2433,9 +2432,7 @@ sub issuerForAuthUser { $self->lmLog( "No rule found for IssuerDB $issuerDBtype", 'debug' ); } - $self->lmLog( - "User $user allowed to use IssuerDB $issuerDBtype", - 'debug' ); + $self->lmLog( "User $user allowed to use IssuerDB $issuerDBtype", 'debug' ); # Register IssuerDB module in session $self->addSessionValue( '_issuerDB', $issuerDBtype, $self->{id} ); @@ -2553,6 +2550,27 @@ sub autoPost { return PE_REDIRECT; } +## @method HASHREF getCustomTemplateParameters() +# Find custom templates parameters +# @return Custom parameters +sub getCustomTemplateParameters { + + my $self = shift; + my $customTplParams = {}; + + foreach ( keys %$self ) { + next unless ( $_ =~ /^tpl_(.+)$/ ); + my $tplParam = $1; + my $tplValue = $self->{ "tpl_" . $tplParam }; + $self->lmLog( "Set custom template parameter $tplParam with $tplValue", + 'debug' ); + + $customTplParams->{$tplParam} = $tplValue; + } + + return $customTplParams; +} + 1; __END__