From 4f41abed3e20e7e41fbb076695f5022bccc2e2e9 Mon Sep 17 00:00:00 2001 From: Terran McCanna Date: Thu, 1 Dec 2022 14:23:06 -0500 Subject: [PATCH] Online Renewal - Prevent user from re-submitting renewal after complete Signed-off-by: Terran McCanna --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm | 5 ++++- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 1a8177a93b..a04edf0014 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -200,7 +200,6 @@ sub load_myopac_prefs_notify { my $self = shift; my $e = $self->editor; - my $stat = $self->_load_user_with_prefs; return $stat if $stat; @@ -3556,6 +3555,9 @@ sub check_account_exp { } #determine which message to show (if any) + my $cache = OpenSRF::Utils::Cache->new('global'); + $cache->put_cache('account_renew_ok','false',3600); + if ($ctx->{hastemprenew} eq 1) { #user already has active temp renewal $ctx->{account_renew_message} = '
Your account could only be temporarily renewed because your address changed. Please visit your nearest PINES @@ -3573,6 +3575,7 @@ sub check_account_exp { } else { $ctx->{account_renew_message} = 'Click here to renew your account'; + $cache->put_cache('account_renew_ok','true',3600); } return 1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm index 128efd9a66..e903e90ed3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm @@ -5,6 +5,7 @@ use OpenSRF::Utils::Logger qw/$logger/; use OpenSRF::Utils::JSON; use OpenSRF::Utils qw/:datetime/; use OpenILS::Utils::Fieldmapper; +use OpenSRF::Utils::Cache; use OpenILS::Application::AppUtils; use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Event; @@ -101,10 +102,8 @@ sub log_params { $msg .= "|" if $msg; $msg .= "$p=".$cgi->param($p); } - $logger->info("ECARD: Submit params: $msg"); -#TERRAN - dump out all incoming stuff from form -$logger->error("TERRAN - all incoming params: $msg"); + $logger->info("ECARD: Submit params: $msg"); } sub handle_testmode_api { @@ -149,7 +148,6 @@ sub handle_datamode_api { } sub load_ecard_submit { - my $self = shift; my $ctx = $self->ctx; my $cgi = $self->cgi; @@ -161,6 +159,16 @@ sub load_ecard_submit { $update_type = 'register'; } + #If this is a renewal, double-check that they are eligible to renew + my $cache = OpenSRF::Utils::Cache->new('global'); + if ($update_type eq 'renew') { + if ($cache->get_cache("account_renew_ok") && $cache->get_cache("account_renew_ok") eq 'true') { + } else { + $logger->error("ERENEW - User not in correct status to renew account"); + return $self->compile_response; + } + } + $self->log_params; my $testmode = $cgi->param('testmode') || ''; @@ -230,6 +238,8 @@ sub load_ecard_submit { } else { $ctx->{response}->{temp_renew} = 0; } + #set renewal flag in cache to false to prevent user from refreshing the page and submitting again + $cache->put_cache('account_renew_ok','false',3600); } else { $ctx->{response}->{barcode} = $ctx->{user}->card->barcode; } @@ -282,9 +292,6 @@ sub compile_response { $ctx->{response} = OpenSRF::Utils::JSON->perl2JSON($ctx->{response}); $logger->info("ECARD responding with " . $ctx->{response}); -#TERRAN TEST - $logger->error("TERRAN - response being sent to Quipu is: " . $ctx->{response}); - return Apache2::Const::OK; } -- 2.11.0