-
Notifications
You must be signed in to change notification settings - Fork 7
/
controllers.rb
67 lines (52 loc) · 1.72 KB
/
controllers.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
ActionController::Base.class_exec do
# TODO: add a descriptive comment and document this magic in the readme
include UserSessionManagement
include ApplicationHelper
include OSU::OsuHelper
include LocaleSelector
include RequireRecentSignin
include AuthenticateMethods
include ContractsNotRequired
helper_method :contracts_not_required
helper OSU::OsuHelper, ApplicationHelper, UserSessionManagement
before_action :save_redirect
before_action :set_locale
before_action :complete_signup_profile
fine_print_require :general_terms_of_use, :privacy_policy, unless: :disable_fine_print
protected
def complete_signup_profile
return true if request.format != :html || request.options?
redirect_to '/signup/profile' if current_user.is_needs_profile?
# TODO: uncomment this line after fixing openstax_path_prefixer
# redirect_to main_app.signup_profile_path if current_user.is_needs_profile?
end
def security_log(event_type, event_data = {})
user = event_data[:user]
if respond_to?(:current_api_user)
api_user = current_api_user
user ||= api_user.human_user
application = api_user.application
else
user ||= current_user
application = nil
end
SecurityLog.create!(
user: user.try(:is_anonymous?) ? nil : user,
application: application,
remote_ip: request.remote_ip,
event_type: event_type,
event_data: event_data
)
end
def save_redirect
return true if request.format != :html || request.options?
url = params[:r]
return true if url.blank? || !Host.trusted?(url)
store_url(url: url)
end
def disable_fine_print
request.options? ||
contracts_not_required ||
current_user.is_anonymous?
end
end