Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/controllers/fees_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'jwt'

class FeesController < ApplicationController

# This will be needed for transaction_complete since Paypal will hit that
protect_from_forgery with: :null_session

Expand All @@ -9,6 +10,8 @@ def index
decoded_token = JWT.decode @jwt, nil, false
@alma_id = decoded_token.first['userName']
@fees = FeesPayment.new(alma_id: @alma_id)
rescue ActionController::ParameterMissing
redirect_to 'https://www.lib.berkeley.edu/find/borrow-renew?section=pay-fees', allow_other_host: true
rescue JWT::DecodeError
redirect_to(action: :transaction_error)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/request/fees_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def base_url_for(user_id = nil)
allow(Rails.application.config).to receive(:alma_api_key).and_return(alma_api_key)
end

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

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