From 47e2f67e9c19dfb3e1ffff14aa6137d518cbe3c3 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 16 Apr 2018 16:04:26 -0300 Subject: [PATCH] Bug 20568: Move value => client_id + secret This patch addresses the request from Julian that api keys are expected to be client id/secret pairs. It does so by - Adding 'client_id' and 'secret' columns - Removing 'value' Tests got adjusted and so controller scripts and templates. Both libs and tests changes have been squashed. This ones remain in order to keep Owen's attribution on the template changes and avoid rebase conflicts. --- .../prog/en/includes/members-toolbar.inc | 2 +- .../prog/en/modules/members/apikeys.tt | 16 +++++++++------- .../bootstrap/en/modules/opac-apikeys.tt | 12 +++++++----- members/apikeys.pl | 12 ++++++------ opac/opac-apikeys.pl | 13 ++++++------- 5 files changed, 29 insertions(+), 26 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 280368bcb5..0c731b5a00 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -61,7 +61,7 @@ [% END %] [% IF CAN_user_borrowers_edit_borrowers %] -
  • Manage API keys
  • +
  • Manage API keys
  • [% ELSE %]
  • Manage API keys
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt index e710efdd2c..93ef624a51 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt @@ -27,7 +27,7 @@
    - Generate new key + Generate new client id/secret pair
    1. @@ -42,13 +42,14 @@
      [% IF api_keys && api_keys.size > 0 %]

      - +

      - + + @@ -57,18 +58,19 @@ [% FOREACH key IN api_keys %] - + +
      DescriptionKeyClient IDSecret Active Actions
      [% key.description %][% key.value %][% key.client_id %][% key.secret %] [% IF key.active %]Yes[% ELSE %]No[% END %]
      - +
      - + [% IF key.active %] @@ -83,7 +85,7 @@
      [% ELSE %] -
      No keys defined for the current patron. Generate a new key
      + [% END %]
      diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt index 7feecdcda5..7aaddf41bd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt @@ -33,7 +33,7 @@

      - Generate new key + Generate new client id/secret pair @@ -48,7 +48,8 @@ Description - Key + Client ID + Secret Active Actions @@ -57,16 +58,17 @@ [% FOREACH key IN api_keys %] [% key.description %] - [% key.value %] + [% key.client_id %] + [% key.secret %] [% IF key.active %]Yes[% ELSE %]No[% END %] - +
      - + [% IF key.active %] diff --git a/members/apikeys.pl b/members/apikeys.pl index 183483bbbb..975ca86e5b 100755 --- a/members/apikeys.pl +++ b/members/apikeys.pl @@ -67,8 +67,8 @@ if ($op) { } if ( $op eq 'delete' ) { - my $api_key = $cgi->param('key'); - my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key }); + my $api_key_id = $cgi->param('key'); + my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id }); if ($key) { $key->delete; } @@ -77,8 +77,8 @@ if ($op) { } if ( $op eq 'revoke' ) { - my $api_key = $cgi->param('key'); - my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key }); + my $api_key_id = $cgi->param('key'); + my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id }); if ($key) { $key->active(0); $key->store; @@ -88,8 +88,8 @@ if ($op) { } if ( $op eq 'activate' ) { - my $api_key = $cgi->param('key'); - my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key }); + my $api_key_id = $cgi->param('key'); + my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id }); if ($key) { $key->active(1); $key->store; diff --git a/opac/opac-apikeys.pl b/opac/opac-apikeys.pl index 7a776f3063..66167e8d38 100755 --- a/opac/opac-apikeys.pl +++ b/opac/opac-apikeys.pl @@ -47,7 +47,6 @@ if ( not defined $patron exit; } - my $op = $cgi->param('op'); if ($op) { @@ -63,8 +62,8 @@ if ($op) { } if ($op eq 'delete') { - my $key = $cgi->param('key'); - my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key}); + my $key_id = $cgi->param('key'); + my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id }); if ($api_key) { $api_key->delete; } @@ -73,8 +72,8 @@ if ($op) { } if ($op eq 'revoke') { - my $key = $cgi->param('key'); - my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key }); + my $key_id = $cgi->param('key'); + my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id }); if ($api_key) { $api_key->active(0); $api_key->store; @@ -84,8 +83,8 @@ if ($op) { } if ($op eq 'activate') { - my $key = $cgi->param('key'); - my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key }); + my $key_id = $cgi->param('key'); + my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id }); if ($api_key) { $api_key->active(1); $api_key->store; -- 2.17.0