2017-12-28 19:44:11 +01:00
|
|
|
module Manager
|
|
|
|
class ApplicationController < Administrate::ApplicationController
|
|
|
|
before_action :authenticate_administration!
|
|
|
|
before_action :default_params
|
|
|
|
|
|
|
|
def default_params
|
2018-11-06 18:32:35 +01:00
|
|
|
params[resource_name] ||= {
|
|
|
|
order: "created_at",
|
|
|
|
direction: "desc"
|
|
|
|
}
|
2017-12-28 19:44:11 +01:00
|
|
|
end
|
2018-01-17 12:13:26 +01:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def authenticate_administration!
|
2020-11-04 16:35:15 +01:00
|
|
|
if administration_signed_in? && current_administration.otp_required_for_login?
|
2018-01-17 12:13:26 +01:00
|
|
|
super
|
2020-11-04 16:35:15 +01:00
|
|
|
elsif administration_signed_in?
|
|
|
|
redirect_to edit_administration_otp_path
|
2018-01-17 12:13:26 +01:00
|
|
|
else
|
2020-11-04 17:56:23 +01:00
|
|
|
redirect_to new_administration_session_path
|
2018-01-17 12:13:26 +01:00
|
|
|
end
|
|
|
|
end
|
2019-11-18 23:11:38 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# private method called by rails fwk
|
|
|
|
# see https://github.com/roidrage/lograge
|
|
|
|
def append_info_to_payload(payload)
|
|
|
|
super
|
|
|
|
|
|
|
|
payload.merge!({
|
|
|
|
user_agent: request.user_agent,
|
|
|
|
user_id: current_user&.id,
|
|
|
|
user_email: current_user&.email
|
|
|
|
}.compact)
|
|
|
|
|
|
|
|
if browser.known?
|
|
|
|
payload.merge!({
|
|
|
|
browser: browser.name,
|
|
|
|
browser_version: browser.version.to_s,
|
|
|
|
platform: browser.platform.name
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
payload
|
|
|
|
end
|
2017-12-28 19:44:11 +01:00
|
|
|
end
|
|
|
|
end
|