Bugzilla – Attachment 143888 Details for
Bug 32203
Refactor checkauth() auth rejected to improve maintainability
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32203: Add render_auth_page() function
Bug-32203-Add-renderauthpage-function.patch (text/plain), 9.18 KB, created by
David Cook
on 2022-11-15 01:13:18 UTC
(
hide
)
Description:
Bug 32203: Add render_auth_page() function
Filename:
MIME Type:
Creator:
David Cook
Created:
2022-11-15 01:13:18 UTC
Size:
9.18 KB
patch
obsolete
>From 9b41326ab5effade76829cae44a84441c64d618b Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Tue, 15 Nov 2022 01:10:02 +0000 >Subject: [PATCH] Bug 32203: Add render_auth_page() function > >This change adds a "render_auth_page()" function to C4::Auth for >rendering the login page for a failed auth/login. > >Test plan: >0. Don't apply patch yet >1. In new tab, go to http://localhost:8081/ and do a failed login >2. In new tab, go to http://localhost:8080/ and do a failed login >3. Apply patch >4. In new tab, go to http://localhost:8081/ and do a failed login >5. In new tab, go to http://localhost:8080/ and do a failed login >6. Note how the failed login screens look the same after the patch >--- > C4/Auth.pm | 113 +++++++++++------- > .../bootstrap/en/includes/masthead.inc | 2 +- > .../bootstrap/en/modules/opac-auth.tt | 2 +- > 3 files changed, 70 insertions(+), 47 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index ac73f2d018..60fad22289 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -1342,38 +1342,19 @@ sub checkauth { > my $auth_error = $query->param('auth_error'); > my $template = C4::Templates::gettemplate( $auth_template_name, $type, $query ); > $template->param( >- login => 1, > INPUTS => \@inputs, > script_name => get_script_name(), > casAuthentication => C4::Context->preference("casAuthentication"), > shibbolethAuthentication => $shib, >- suggestion => C4::Context->preference("suggestion"), >- virtualshelves => C4::Context->preference("virtualshelves"), >- LibraryName => "" . C4::Context->preference("LibraryName"), > LibraryNameTitle => "" . $LibraryNameTitle, >- opacuserlogin => C4::Context->preference("opacuserlogin"), >- OpacFavicon => C4::Context->preference("OpacFavicon"), >- opacreadinghistory => C4::Context->preference("opacreadinghistory"), >- opaclanguagesdisplay => C4::Context->preference("opaclanguagesdisplay"), >- OPACUserJS => C4::Context->preference("OPACUserJS"), >- opacbookbag => "" . C4::Context->preference("opacbookbag"), >- OpacCloud => C4::Context->preference("OpacCloud"), >- OpacTopissue => C4::Context->preference("OpacTopissue"), >- OpacAuthorities => C4::Context->preference("OpacAuthorities"), >- OpacBrowser => C4::Context->preference("OpacBrowser"), >- TagsEnabled => C4::Context->preference("TagsEnabled"), >- OPACUserCSS => C4::Context->preference("OPACUserCSS"), > intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), > intranetstylesheet => C4::Context->preference("intranetstylesheet"), >- IntranetNav => C4::Context->preference("IntranetNav"), > IntranetFavicon => C4::Context->preference("IntranetFavicon"), > IntranetUserCSS => C4::Context->preference("IntranetUserCSS"), > IntranetUserJS => C4::Context->preference("IntranetUserJS"), > IndependentBranches => C4::Context->preference("IndependentBranches"), > AutoLocation => C4::Context->preference("AutoLocation"), > wrongip => $info{'wrongip'}, >- PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"), >- PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"), > opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, > too_many_login_attempts => ( $patron and $patron->account_locked ), > password_has_expired => ( $patron and $patron->password_expired ), >@@ -1382,7 +1363,6 @@ sub checkauth { > > $template->param( SCO_login => 1 ) if ( $query->param('sco_user_login') ); > $template->param( SCI_login => 1 ) if ( $query->param('sci_user_login') ); >- $template->param( OpacPublic => C4::Context->preference("OpacPublic") ); > $template->param( loginprompt => 1 ) unless $info{'nopermission'}; > if ( $auth_state eq 'additional-auth-needed' ) { > my $patron = Koha::Patrons->find( { userid => $userid } ); >@@ -1399,17 +1379,6 @@ sub checkauth { > ); > } > >- if ( $type eq 'opac' ) { >- require Koha::Virtualshelves; >- my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( >- { >- public => 1, >- } >- ); >- $template->param( >- some_public_shelves => $some_public_shelves, >- ); >- } > > if ($cas) { > >@@ -1456,25 +1425,79 @@ sub checkauth { > } > } > >- $template->param( >- LibraryName => C4::Context->preference("LibraryName"), >- ); > $template->param(%info); > >- # $cookie = $query->cookie(CGISESSID => $session->id >- # ); >- print $query->header( >- { type => 'text/html', >- charset => 'utf-8', >- cookie => $cookie, >- 'X-Frame-Options' => 'SAMEORIGIN', >- -sameSite => 'Lax' >- } >- ), >- $template->output; >+ __PACKAGE__->render_auth_page({ >+ controller => $query, >+ cookie => $cookie, >+ template => $template, >+ type => $type, >+ }); > safe_exit; > } > >+=head2 render_auth_page >+ >+ C4::Auth->render_auth_page({ >+ controller => $query, >+ cookie => $cookie, >+ template => $template, >+ type => $type, >+ }); >+ >+Given a controller object, a cookie, a template, and a type, this >+function renders a UI page for the user to login/authenticate for >+Koha. >+ >+=cut >+ >+sub render_auth_page { >+ my ($class,$args) = @_; >+ my $controller = $args->{controller}; >+ my $cookie = $args->{cookie}; >+ my $template = $args->{template}; >+ my $type = $args->{type}; >+ if ($template){ >+ if ($type){ >+ if ($type eq 'opac'){ >+ #LISTS >+ require Koha::Virtualshelves; >+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ public => 1, >+ } >+ ); >+ #/LISTS >+ $template->param( >+ some_public_shelves => $some_public_shelves, >+ opaclanguagesdisplay => C4::Context->preference("opaclanguagesdisplay"), >+ ); >+ } >+ else { >+ $template->param ( >+ login => 1, >+ ); >+ } >+ } >+ } >+ if ( $controller ){ >+ if ( $controller->isa('CGI') ){ >+ my $query = $controller; >+ print $query->header( >+ { type => 'text/html', >+ charset => 'utf-8', >+ cookie => $cookie, >+ 'X-Frame-Options' => 'SAMEORIGIN', >+ -sameSite => 'Lax' >+ } >+ ); >+ if ($template){ >+ print $template->output; >+ } >+ } >+ } >+} >+ > =head2 check_api_auth > > ($status, $cookie, $sessionId) = check_api_auth($query, $userflags); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index 941805f7a6..de8cd9869f 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -153,7 +153,7 @@ > > </div> <!-- / header-region --> > >- [% IF ( OpacPublic ) %] >+ [% IF ( Koha.Preference('OpacPublic') ) %] > <div class="container-fluid"> > [% UNLESS ( advsearch ) %] > <div class="row"> >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 999e6aaa7e..0c18bc84f7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt >@@ -251,7 +251,7 @@ > <a href="/cgi-bin/koha/opac-password-recovery.pl">Forgot your password?</a> > </div> > [% END %] >- [% IF PatronSelfRegistration && PatronSelfRegistrationDefaultCategory %] >+ [% IF Koha.Preference('PatronSelfRegistration') && Koha.Preference('PatronSelfRegistrationDefaultCategory') %] > <div id="registrationinstructions"> > <span> > <a href="/cgi-bin/koha/opac-memberentry.pl">You may register here.</a> >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32203
: 143888