Skip to content

Commit b7fa544

Browse files
committed
redirecting if jwt is not see for /fees path
1 parent 479c2c9 commit b7fa544

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/controllers/fees_controller.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
require 'jwt'
22

33
class FeesController < ApplicationController
4+
5+
rescue_from ActionController::ParameterMissing, with: :missing_params
6+
47
# This will be needed for transaction_complete since Paypal will hit that
58
protect_from_forgery with: :null_session
69

@@ -13,6 +16,10 @@ def index
1316
redirect_to(action: :transaction_error)
1417
end
1518

19+
def missing_params(_error)
20+
redirect_to 'https://lib.berkeley.edu/find/borrow-renew?section=pay-fees', allow_other_host: true
21+
end
22+
1623
def efee
1724
@jwt = params.require(:jwt)
1825
secret = EfeesInvoice.secret
@@ -73,8 +80,6 @@ def transaction_complete
7380
render json: { status: 'silent post received' }
7481
end
7582

76-
private
77-
7883
def authorize!
7984
return if Rails.env.development?
8085

spec/request/fees_request_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def base_url_for(user_id = nil)
1212
allow(Rails.application.config).to receive(:alma_api_key).and_return(alma_api_key)
1313
end
1414

15-
it 'shows a Bad Request error if request has no jwt' do
15+
it 'redirects to the fallback URL if there is no jwt' do
1616
get fees_path
17-
expect(response).to have_http_status(:bad_request)
17+
expect(response).to redirect_to('https://lib.berkeley.edu/find/borrow-renew?section=pay-fees')
1818
end
1919

2020
it 'redirects to error page if request has a non-existant alma id' do

0 commit comments

Comments
 (0)