Skip to content

Commit ebc5e9f

Browse files
committed
only redirecting if jwt is missing for the index action for fees
1 parent 8d7a504 commit ebc5e9f

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

app/controllers/fees_controller.rb

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
class FeesController < ApplicationController
44

5-
rescue_from ActionController::ParameterMissing, with: :missing_params
6-
75
# This will be needed for transaction_complete since Paypal will hit that
86
protect_from_forgery with: :null_session
97

108
def index
11-
@jwt = params.require(:jwt)
12-
decoded_token = JWT.decode @jwt, nil, false
13-
@alma_id = decoded_token.first['userName']
14-
@fees = FeesPayment.new(alma_id: @alma_id)
15-
rescue JWT::DecodeError
16-
redirect_to(action: :transaction_error)
9+
@jwt = params.require(:jwt)
10+
decoded_token = JWT.decode @jwt, nil, false
11+
@alma_id = decoded_token.first['userName']
12+
@fees = FeesPayment.new(alma_id: @alma_id)
13+
rescue ActionController::ParameterMissing
14+
redirect_to 'https://www.lib.berkeley.edu/find/borrow-renew?section=pay-fees', allow_other_host: true
15+
rescue JWT::DecodeError
16+
redirect_to(action: :transaction_error)
1717
end
1818

1919
def efee
@@ -78,10 +78,6 @@ def transaction_complete
7878

7979
private
8080

81-
def missing_params(_error)
82-
redirect_to 'https://lib.berkeley.edu/find/borrow-renew?section=pay-fees', allow_other_host: true
83-
end
84-
8581
def authorize!
8682
return if Rails.env.development?
8783

spec/request/fees_request_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def base_url_for(user_id = nil)
1414

1515
it 'redirects to the fallback URL if there is no jwt' do
1616
get fees_path
17-
expect(response).to redirect_to('https://lib.berkeley.edu/find/borrow-renew?section=pay-fees')
17+
expect(response).to redirect_to('https://www.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)