Bug 38544: OPAC Modal login not generated when OPAC login is disabled

When OPAC login is disabled (system preference opacuserlogin),
the modal login should not exist in HTML.

Note the access to opac-user.pl shows a message and not auth form.

You may look at commit with : git diff --ignore-space-change

Test plan :
1.1) Set system preference opacuserlogin to "Allow"
1.2) Go to OPAC main page
1.3) Check you see in source : div id="loginModal"
1.4) Click on "Log in to your account"
1.5) Check you see the modal login
2.1) Set system preference opacuserlogin to "Don't allow"
2.2) Go to OPAC main page
2.3) Check you do not see in source : div id="loginModal"

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Fridolin Somers 2024-11-27 10:55:01 +01:00 committed by Katrin Fischer
parent be6ebd4b9a
commit a045ac1e96
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 80 additions and 77 deletions

View File

@ -387,86 +387,89 @@
</div> <!-- /.container-fluid -->
[% END # / OpacPublic %]
<!-- Login form hidden by default, used for modal window -->
<div id="loginModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="modalLoginLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="modalLoginLabel">Log in to your account</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="modalAuth">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="has-search-query" id="has-search-query" value="" />
<div class="modal-body">
[% IF ( Koha.Preference('GoogleOpenIDConnect') == 1 ) %]
<a href="/cgi-bin/koha/svc/auth/googleopenidconnect" class="btn btn-light" id="openid_connect"><i class="fa-brands fa-google" aria-hidden="true"></i> Log in with Google</a>
<p>If you do not have a Google account, but do have a local account, you can still log in: </p>
[% END # /IF GoogleOpenIDConnect %]
[% IF ( shibbolethAuthentication ) %]
[% IF ( invalidShibLogin ) %]
<!-- This is what is displayed if shibboleth login has failed to match a koha user -->
<div class="alert alert-info">
<p>Sorry, your Shibboleth identity does not match a valid library identity. If you have a local login, you may use that below.</p>
</div>
[% ELSE %]
<h3 class="shib_title">Shibboleth login</h3>
<p><a id="shib_url" class="shib_url" href="[% shibbolethLoginUrl | $raw %]">Log in using a Shibboleth account</a>.</p>
[% UNLESS Koha.Preference('opacShibOnly') %]
<h3 class="shib_local_title">Local login</h3>
[% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
<!-- Login form hidden by default, used for modal window -->
<div id="loginModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="modalLoginLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="modalLoginLabel">Log in to your account</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="modalAuth">
[% INCLUDE 'csrf-token.inc' %]
<input type="hidden" name="has-search-query" id="has-search-query" value="" />
<div class="modal-body">
[% IF ( Koha.Preference('GoogleOpenIDConnect') == 1 ) %]
<a href="/cgi-bin/koha/svc/auth/googleopenidconnect" class="btn btn-light" id="openid_connect"><i class="fa-brands fa-google" aria-hidden="true"></i> Log in with Google</a>
<p>If you do not have a Google account, but do have a local account, you can still log in: </p>
[% END # /IF GoogleOpenIDConnect %]
[% IF ( shibbolethAuthentication ) %]
[% IF ( invalidShibLogin ) %]
<!-- This is what is displayed if shibboleth login has failed to match a koha user -->
<div class="alert alert-info">
<p>Sorry, your Shibboleth identity does not match a valid library identity. If you have a local login, you may use that below.</p>
</div>
[% ELSE %]
<h3 class="shib_title">Shibboleth login</h3>
<p><a id="shib_url" class="shib_url" href="[% shibbolethLoginUrl | $raw %]">Log in using a Shibboleth account</a>.</p>
[% UNLESS Koha.Preference('opacShibOnly') %]
<h3 class="shib_local_title">Local login</h3>
[% END %]
[% END %]
[% END %]
[% END %]
[% UNLESS Koha.Preference('opacShibOnly') %]
[% SET identity_providers = AuthClient.get_providers('opac') %]
[% IF ( ! identity_providers.empty ) %]
[% FOREACH provider IN identity_providers %]
<p class="clearfix">
<a href="[% provider.url | url %]" class="btn btn-light col-md-12" id="provider_[% provider.code | html %]">
[% IF provider.icon_url %]
<img src="[% provider.icon_url | url %]" />
[% ELSE %]
<i class="fa fa-user" aria-hidden="true"></i>
[% END %]
Log in with [% provider.description | html %]
</a>
</p>
[% END %]
<hr/>
<p>If you do not have an external account, but do have a local account, you can still log in: </p>
[% END # /IF identity_providers.size %]
<input type="hidden" name="koha_login_context" value="opac" />
<fieldset class="brief">
<div class="local-login">
[% PROCESS login_label for="muserid" %]<input type="text" id="muserid" name="login_userid" autocomplete="off" />
<label for="mpassword">Password:</label><input type="password" id="mpassword" name="login_password" autocomplete="off" />
<fieldset class="action">
<input type="hidden" name="op" value="cud-login" />
<input type="submit" class="btn btn-primary" value="Log in" />
</fieldset>
</div>
[% IF OpacLoginInstructions %]
<div id="nologininstructions-modal" class="nologininstructions">
[% PROCESS koha_news_block news => OpacLoginInstructions %]
[% UNLESS Koha.Preference('opacShibOnly') %]
[% SET identity_providers = AuthClient.get_providers('opac') %]
[% IF ( ! identity_providers.empty ) %]
[% FOREACH provider IN identity_providers %]
<p class="clearfix">
<a href="[% provider.url | url %]" class="btn btn-light col-md-12" id="provider_[% provider.code | html %]">
[% IF provider.icon_url %]
<img src="[% provider.icon_url | url %]" />
[% ELSE %]
<i class="fa fa-user" aria-hidden="true"></i>
[% END %]
Log in with [% provider.description | html %]
</a>
</p>
[% END %]
<hr/>
<p>If you do not have an external account, but do have a local account, you can still log in: </p>
[% END # /IF identity_providers.size %]
<input type="hidden" name="koha_login_context" value="opac" />
<fieldset class="brief">
<div class="local-login">
[% PROCESS login_label for="muserid" %]<input type="text" id="muserid" name="login_userid" autocomplete="off" />
<label for="mpassword">Password:</label><input type="password" id="mpassword" name="login_password" autocomplete="off" />
<fieldset class="action">
<input type="hidden" name="op" value="cud-login" />
<input type="submit" class="btn btn-primary" value="Log in" />
</fieldset>
</div>
[% END %]
[% IF Koha.Preference('OpacPasswordChange') && Categories.can_any_reset_password %]
<div id="forgotpassword-modal" class="forgotpassword">
<p><a href="/cgi-bin/koha/opac-password-recovery.pl">Forgot your password?</a></p>
</div>
[% END %]
[% IF Koha.Preference('PatronSelfRegistration') && Categories.all( categorycode => Koha.Preference('PatronSelfRegistrationDefaultCategory') ).count %]
<div id="patronregistration-modal" class="patronregistration">
<p><a href="/cgi-bin/koha/opac-memberentry.pl">Create an account</a></p>
</div>
[% END %]
</fieldset>
[% END %]
</div>
</form> <!-- /#auth -->
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div> <!-- /#modalAuth -->
[% IF OpacLoginInstructions %]
<div id="nologininstructions-modal" class="nologininstructions">
[% PROCESS koha_news_block news => OpacLoginInstructions %]
</div>
[% END %]
[% IF Koha.Preference('OpacPasswordChange') && Categories.can_any_reset_password %]
<div id="forgotpassword-modal" class="forgotpassword">
<p><a href="/cgi-bin/koha/opac-password-recovery.pl">Forgot your password?</a></p>
</div>
[% END %]
[% IF Koha.Preference('PatronSelfRegistration') && Categories.all( categorycode => Koha.Preference('PatronSelfRegistrationDefaultCategory') ).count %]
<div id="patronregistration-modal" class="patronregistration">
<p><a href="/cgi-bin/koha/opac-memberentry.pl">Create an account</a></p>
</div>
[% END %]
</fieldset>
[% END %]
</div>
</form> <!-- /#auth -->
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div> <!-- /#modalAuth -->
[% END # / IF opacuserlogin %]
[% IF Koha.Preference( 'CookieConsent' ) %]
<!-- Cookie consent bar -->
<div id="cookieConsentBar" aria-hidden="true">