Koha-clms/members
Tomás Cohen Arazi bc6110ae10
Bug 20638: Update apikeys.pl and template with proper exception handling
This patch comprehensively updates the API keys management interface
to use the new revoke() and activate() methods with proper exception
handling.

Controller changes (members/apikeys.pl):
- Add Try::Tiny and Scalar::Util imports for exception handling
- Replace direct field manipulation (active(0)/active(1)) with proper
  method calls (revoke()/activate()) to ensure logging
- Wrap method calls in try/catch blocks to handle specific exceptions:
  * Koha::Exceptions::ApiKey::AlreadyRevoked
  * Koha::Exceptions::ApiKey::AlreadyActive
- Implement standard Koha messages pattern with @messages array
- Improve code structure with elsif chain instead of multiple if statements
- Add proper error handling for key_not_found cases
- Include error_string for unhandled exceptions to aid debugging

Template changes (koha-tmpl/.../apikeys.tt):
- Add comprehensive error message handling for all exception types:
  * already_revoked: Clear message for revoked keys
  * already_active: Clear message for active keys
  * key_not_found: Message for missing keys
  * unhandled_exception: Generic message with detailed error string

Key benefits:
- All API key state changes are now properly logged when ApiKeyLog is enabled
- Better user experience with specific, actionable error messages
- Robust exception handling prevents crashes and provides debugging info
- Improved code maintainability and extensibility

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-01-22 09:26:01 -07:00
..
accountline-details.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
alert-subscriptions.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
apikeys.pl Bug 20638: Update apikeys.pl and template with proper exception handling 2026-01-22 09:26:01 -07:00
boraccount.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
cancel-charge.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
default_messageprefs.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
deletemem.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
discharge.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
discharges.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
files.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
holdshistory.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
housebound.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ill-requests.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
mancredit.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
maninvoice.pl Bug 41212: Sort debit_types for manual invoice by description 2025-11-19 12:28:17 -07:00
member-flags.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
member-password.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
member.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
memberentry.pl Bug 39014: (follow-up) Refactoring and renaming to can_be_guaranteed_by 2025-12-30 07:49:05 -07:00
members-home.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
members-update-do.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
members-update.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
merge-patrons.pl Bug 35830: Add merge_borrowers subpermission 2025-10-31 15:26:14 -06:00
mod_debarment.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
moremember.pl Bug 40886: Ensure patron messages display in proper chronological order 2025-10-06 09:15:22 -06:00
notices.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
patronimage.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
pay.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
paycollect.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
print_overdues.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
printfeercpt.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
printinvoice.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
printnotice.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
printslip.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
purchase-suggestions.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
readingrec.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
recallshistory.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
routing-lists.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
setstatus.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
statistics.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
summary-print.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
two_factor_auth.pl Bug 30724: Fix selenium tests - fix logic if no borrowernumber passed 2025-10-16 15:20:16 -06:00
update-child.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00