-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.rb
129 lines (107 loc) · 3.93 KB
/
account.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
require "sinatra"
require "sinatra/namespace"
require "sinatra/reloader" if development?
require "sinatra/flash"
require "redcarpet"
require "omniauth"
require "omniauth_openid_connect"
require "alma_rest_client"
require "jwt"
require "byebug" if development?
require "ostruct"
# Monkey patch for omniauth_openid_connect -> openid_connect -> webfinger -> httpclient SSL errors
# require_relative "./lib/monkey_httpclient"
require_relative "lib/services"
require_relative "lib/entities/entities"
require_relative "lib/entities/pages"
require_relative "lib/entities/empty_state"
require_relative "lib/navigation/navigation"
require_relative "lib/navigation/page"
require_relative "lib/navigation/horizontal_nav"
require_relative "lib/navigation/sidebar"
require_relative "lib/navigation/user_dropdown"
require_relative "lib/navigation/title"
require_relative "lib/navigation/description"
require_relative "lib/utility"
require_relative "lib/illiad_client"
require_relative "lib/circ_history_client"
require_relative "lib/table_controls"
require_relative "lib/pagination/pagination"
require_relative "lib/pagination/pagination_decorator"
require_relative "lib/circulation_history_settings_text"
require_relative "models/illiad_patron"
require_relative "models/patron"
require_relative "models/session_patron"
require_relative "models/response/response"
require_relative "models/response/renew_response_presenter"
require_relative "models/fines/nelnet"
require_relative "models/fines/fines"
require_relative "models/fines/receipt"
require_relative "models/items/items"
require_relative "models/items/item"
require_relative "models/items/alma/alma_item"
require_relative "models/items/alma/loans"
require_relative "models/items/alma/requests"
require_relative "models/items/circ_history/circ_history_item"
require_relative "models/items/interlibrary_loan/interlibrary_loan_item"
require_relative "models/items/interlibrary_loan/interlibrary_loan_items"
require_relative "models/items/interlibrary_loan/document_delivery"
require_relative "models/items/interlibrary_loan/interlibrary_loans"
require_relative "models/items/interlibrary_loan/interlibrary_loan_requests"
require_relative "models/items/interlibrary_loan/past_document_delivery"
require_relative "models/items/interlibrary_loan/past_interlibrary_loans"
require_relative "models/items/interlibrary_loan/pending_document_delivery"
require_relative "lib/routes/auth"
require_relative "lib/routes/monitoring"
require_relative "lib/routes/current_checkouts"
require_relative "lib/routes/pending_requests"
require_relative "lib/routes/past_activity"
require_relative "lib/routes/settings"
require_relative "lib/routes/fines_and_fees"
helpers StyledFlash
enable :sessions
set :session_secret, ENV["RACK_COOKIE_SECRET"]
set server: "puma"
use Rack::Logger
before do
pass if ["auth", "session_switcher", "logout", "login", "-"].include? request.path_info.split("/")[1]
if dev_login?
if !session[:uniqname]
redirect "/session_switcher?uniqname=#{CGI.escape("[email protected]")}"
end
pass
end
if !session[:authenticated] || Time.now.utc > session[:expires_at]
session[:path_before_login] = request.path_info
redirect "/login"
end
end
helpers do
def dev_login?
ENV["WEBLOGIN_ON"] == "false" && settings.environment == :development
end
end
post "/table-controls" do
url_generator = TableControls::URLGenerator.for(show: params["show"], sort: params["sort"], referrer: request.referrer)
redirect url_generator.to_s
end
# :nocov:
get "/session_switcher" do
patron = SessionPatron.new(params[:uniqname])
patron.to_h.each { |k, v| session[k] = v }
redirect back
end
# :nocov:
get "/" do
erb :"account-overview/index", locals: {cards: Navigation.cards}
end
get "/favorites" do
redirect "https://apps.lib.umich.edu/my-account/favorites"
end
not_found do
erb :empty_state
end
error do
flash.now[:error] = "Sorry there was an error - " + env["sinatra.error"].message
erb :empty_state
end