From 5cf8bbfb7aea34b6367dfbbfb9d73f88851507fb Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 2 May 2018 15:55:31 -0300 Subject: [PATCH] Bug 20624: Make staff client respect RESTOAuth2ClientCredentials This patch makes the staff client UI respect the RESTOAuth2ClientCredentials syspref. To test: - Make sure RESTOAuth2ClientCredentials is "Don't enable" - Go to a patron's detail page => SUCCESS: The 'More' dropdown doesn't show the API keys management link. - Enable RESTOAuth2ClientCredentials - Reload => SUCCESS: The 'More' dropdown shows the API keys management link - Click on the API keys management link => SUCCESS: You can edit the api keys - Disable the syspref - Reload => SUCCESS: You are presented an error 400 page. - Sign off :-D Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- .../intranet-tmpl/prog/en/includes/members-toolbar.inc | 10 ++++++---- members/apikeys.pl | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 74a83f6ee7..9b5524d4c1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -60,10 +60,12 @@
  • Discharge
  • [% END %] - [% IF CAN_user_borrowers_edit_borrowers %] -
  • Manage API keys
  • - [% ELSE %] -
  • Manage API keys
  • + [% IF Koha.Preference('RESTOAuth2ClientCredentials') %] + [% IF CAN_user_borrowers_edit_borrowers %] +
  • Manage API keys
  • + [% ELSE %] +
  • Manage API keys
  • + [% END %] [% END %] [% IF CAN_user_borrowers_edit_borrowers %] diff --git a/members/apikeys.pl b/members/apikeys.pl index e20e010ec4..9d1a4f12d5 100755 --- a/members/apikeys.pl +++ b/members/apikeys.pl @@ -45,7 +45,8 @@ my $api_key = $cgi->param('key') // ''; $patron = Koha::Patrons->find($patron_id) if $patron_id; -if ( not defined $patron ) { +if ( not defined $patron or + not C4::Context->preference('RESTOAuth2ClientCredentials') ) { # patron_id invalid -> exit print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); # escape early -- 2.39.5