From c613a039c8576efd82fc24fd22f754c24341bae0 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 15 Jan 2016 15:46:46 -0500 Subject: [PATCH] Bug 12663 - SCOUserCSS and SCOUserJS ignored on selfcheck login page Currently if not logged in when browsing to http://YOURCATALOG/cgi-bin/koha/sco/sco-main.pl You are redirected to opac-auth.pl and SCOUserCSS and SCOUserJS are not loaded. This patch adds new opac-auth.tt file for authenticating SCO users which loads these files and redirects a login to the SCO module instead of the patron account Common code between opac-auth and sco-auth is mostly alternate login info and has been move to alt-auth.inc To test: 1 - Verify that normal login works on both staff and opac 2 - Verify that SCO login goes to a new page 3 - Enter changes into SCOUserJS and SCOUserCSS and observe these are present on SOC log in page 4 - Verify that a logged in opac user without permissions cannot access the self-checkout module 5 - Verify that AutoSelfCheckAllowed and associated system preferences function as expected 6 - Verify the AutoSelfCheck user is logged out if they attempt to visit another page Bonus points for verifying all alternate methonds of login function as expected Sponsored by Northeast Kansas Libary System (NEKLS) www.nekls.org --- C4/Auth.pm | 11 ++- .../opac-tmpl/bootstrap/en/includes/alt-auth.inc | 79 ++++++++++++++++++++ .../bootstrap/en/includes/doc-head-close.inc | 4 +- .../bootstrap/en/includes/opac-bottom.inc | 4 +- .../opac-tmpl/bootstrap/en/modules/opac-auth.tt | 81 +------------------- .../opac-tmpl/bootstrap/en/modules/sco-auth.tt | 86 ++++++++++++++++++++++ opac/sco/sco-main.pl | 2 +- 7 files changed, 183 insertions(+), 84 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/alt-auth.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/sco-auth.tt diff --git a/C4/Auth.pm b/C4/Auth.pm index cda7ae0..bd06804 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1197,7 +1197,14 @@ sub checkauth { $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi; $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg; - my $template_name = ( $type eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt'; + my $template_name; + if( $type eq 'opac' ) { + $template_name = 'opac-auth.tt' + } + elsif( $type eq 'sco' ){ + $template_name = 'sco-auth.tt' + } + else { $template_name = 'auth.tt' } my $template = C4::Templates::gettemplate( $template_name, $type, $query ); $template->param( branchloop => GetBranchesLoop(), @@ -1243,6 +1250,8 @@ sub checkauth { PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"), persona => C4::Context->preference("Persona"), opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, + SCOUserCSS => C4::Context->preference("SCOUserCSS"), + SCOUserJS => C4::Context->preference("SCOUserJS"), ); $template->param( OpacPublic => C4::Context->preference("OpacPublic") ); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/alt-auth.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/alt-auth.inc new file mode 100644 index 0000000..91bb1c6 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/alt-auth.inc @@ -0,0 +1,79 @@ +[% IF ( shibbolethAuthentication ) %] + + [% IF ( invalidShibLogin ) %] + +
+

+ Sorry, your Shibboleth identity does not match a valid library identity. + [% IF ( casAuthentication ) %] + [% IF ( invalidCasLogin ) %] + +

Sorry, the CAS login also failed, if you have a local login you may use that below.

+ [% ELSE %] + If you have a CAS account, you may use that below. + [% END %] + [% ELSE %] + If you have a local account, you may use that below. + [% END %] +

+
+ [% ELSE %] +

Shibboleth Login

+

If you have a Shibboleth account, + please click here to login + [% END %] + + [% IF ( casAuthentication ) %] +

CAS login

+

If you do not have a Shibboleth account, but you do have a CAS account, + [% ELSE %] +

Local login

+

If you do not have a Shibboleth account, but you do have a local login, then you may login below:

+ [% END %] + +[% END %] + +[% IF ( casAuthentication ) %] + [% IF ( shibbolethAuthentication ) %] + [% IF ( casServerUrl ) %] + please click here to login.

+ [% END %] + [% IF ( casServersLoop ) %] + please choose against which one you would like to authenticate:

+ + [% END %] + [% ELSE %] +

CAS login

+ + [% IF ( invalidCasLogin ) %] + +

Sorry, the CAS login failed.

+ [% END %] + +

If you have a CAS account, + [% IF ( casServerUrl ) %] + please click here to login.

+ [% END %] + + [% IF ( casServersLoop ) %] + please choose against which one you would like to authenticate:

+ + [% END %] + [% END %] + + [% IF ( shibbolethAuthentication ) %] +

Nothing

+ [% ELSE %] +

Local login

+

If you do not have a CAS account, but do have a local account, you can still log in:

+ [% END %] + +[% END # / IF casAuthentication %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc index e346689..a6945b5 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc @@ -37,7 +37,9 @@ [% IF ( bidi ) %] [% END %] -[% IF ( OPACUserCSS ) %][% END %] +[% UNLESS template.name.match('sco-auth.tt') %] + [% IF ( OPACUserCSS ) %][% END %] +[% END %] [% PROCESS cssinclude %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index 30ba396..0965619 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -267,12 +267,14 @@ $(document).ready(function() { [% PROCESS jsinclude %] -[% IF ( OPACUserJS ) %] +[% UNLESS template.name.match('sco-auth.tt') %] + [% IF ( OPACUserJS ) %] + [% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt index 3dc1c56..9b581f9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt @@ -57,86 +57,7 @@ [% END %] - [% IF ( shibbolethAuthentication ) %] - - [% IF ( invalidShibLogin ) %] - -
-

- Sorry, your Shibboleth identity does not match a valid library identity. - [% IF ( casAuthentication ) %] - [% IF ( invalidCasLogin ) %] - -

Sorry, the CAS login also failed, if you have a local login you may use that below.

- [% ELSE %] - If you have a CAS account, you may use that below. - [% END %] - [% ELSE %] - If you have a local account, you may use that below. - [% END %] -

-
- [% ELSE %] -

Shibboleth Login

- -

If you have a Shibboleth account, - please click here to login.

- [% END %] - [% IF ( casAuthentication ) %] -

CAS login

-

If you do not have a Shibboleth account, but you do have a CAS account, - [% ELSE %] -

Local login

-

If you do not have a Shibboleth account, but you do have a local login, then you may login below:

- [% END %] - - [% END %] - - [% IF ( casAuthentication ) %] - [% IF ( shibbolethAuthentication ) %] - [% IF ( casServerUrl ) %] - please click here to login.

- [% END %] - - [% IF ( casServersLoop ) %] - please choose against which one you would like to authenticate:

- - [% END %] - [% ELSE %] -

CAS login

- - [% IF ( invalidCasLogin ) %] - -

Sorry, the CAS login failed.

- [% END %] - -

If you have a CAS account, - [% IF ( casServerUrl ) %] - please click here to login.

- [% END %] - - [% IF ( casServersLoop ) %] - please choose against which one you would like to authenticate:

- - [% END %] - [% END %] - - [% IF ( shibbolethAuthentication ) %] -

Nothing

- [% ELSE %] -

Local login

-

If you do not have a CAS account, but do have a local account, you can still log in:

- [% END %] - - [% END # / IF casAuthentication %] + [% INCLUDE 'alt-auth.inc' %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco-auth.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco-auth.tt new file mode 100644 index 0000000..1d0ec8d --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco-auth.tt @@ -0,0 +1,86 @@ +[% USE Koha %] +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] self-checkout station › + Self-checkout login + +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] +[% IF ( SCOUserCSS ) %][% END %] + +[% INCLUDE 'bodytag.inc' bodyid='sco-login-page' bodyclass='scrollto' %] +[% INCLUDE 'masthead.inc' %] + +
+ + +
+
+
+
+ [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] + [% IF ( nopermission ) %] + +
+

Access denied

+

Sorry, the system doesn't think you have permission to access this page.

+
+ [% END %] + [% END %] + + [% IF ( loginprompt ) %] + +

Log in to your account

+ + [% IF ( timed_out ) %] + +
+

Sorry, your session has timed out. Please log in again.

+
+ [% END %] + + [% IF ( different_ip ) %] + +
+

You are logging from a different IP address. Please log in again.

+
+ [% END %] + + [% IF ( invalid_username_or_password ) %] + +
+

You entered an incorrect username or password. Please try again! And remember, passwords are case sensitive.

+
+ [% END %] + + [% INCLUDE 'alt-auth.inc' %] + + + +
+ [% FOREACH INPUT IN INPUTS %] + + [% END %] + + + +
+ + +
+ + [% END # / IF loginprompt %] +
+
+
+
+ + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] +[% IF ( SCOUserJS ) %][% END %] + +[% END %] + diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index eff549d..a2020a4 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -67,7 +67,7 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({ authnotrequired => 0, flagsrequired => { circulate => "self_checkout" }, query => $query, - type => "opac", + type => "sco", debug => 1, }); -- 2.1.4