From f55f53c76501631126dc234dad3afb26acec4197 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 17 Feb 2020 16:44:37 +0100 Subject: [PATCH] Bug 24663: Handle special cases for recovery password and selfreg MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The password recovery and self-registration features need to be accessible at the OPAC even if not public. Test plan: Self register a new account, then ask for a new password with OpacPublic turned off Signed-off-by: Martin Renvoize Signed-off-by: Tomás Cohen Arazi Signed-off-by: Lucas Gass (cherry picked from commit 5df7a3b6b589e692bec13a8f09258f2c26bfaa2c) --- C4/Auth.pm | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index d5a8e59567..238fcac44c 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -170,7 +170,9 @@ sub get_template_and_user { $in->{'query'}, $in->{'authnotrequired'}, $in->{'flagsrequired'}, - $in->{'type'} + $in->{'type'}, + undef, + $in->{template_name}, ); } @@ -786,9 +788,21 @@ sub checkauth { my $flagsrequired = shift; my $type = shift; my $emailaddress = shift; + my $template_name = shift; $type = 'opac' unless $type; - $authnotrequired = 0 unless C4::Context->preference("OpacPublic"); + unless ( C4::Context->preference("OpacPublic") ) { + my @allowed_scripts_for_private_opac = qw( + opac-memberentry.tt + opac-registration-email-sent.tt + opac-registration-confirmation.tt + opac-memberentry-update-submitted.tt + opac-password-recovery.tt + ); + $authnotrequired = 0 unless grep { $_ eq $template_name } + @allowed_scripts_for_private_opac; + } + my $dbh = C4::Context->dbh; my $timeout = _timeout_syspref(); @@ -1240,8 +1254,8 @@ sub checkauth { $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi; $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg; - my $template_name = ( $type eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt'; - my $template = C4::Templates::gettemplate( $template_name, $type, $query ); + my $auth_template_name = ( $type eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt'; + my $template = C4::Templates::gettemplate( $auth_template_name, $type, $query ); $template->param( login => 1, INPUTS => \@inputs, -- 2.39.5