6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/lcp_ruby/impersonation_controller.rb', line 6
def create
unless can_impersonate_current_user?
redirect_back fallback_location: "/", allow_other_host: false, alert: I18n.t("lcp_ruby.impersonation.not_authorized", default: "You are not authorized to impersonate roles.")
return
end
role = params[:role]
if role.blank?
redirect_back fallback_location: "/", allow_other_host: false, alert: I18n.t("lcp_ruby.impersonation.no_role", default: "No role specified.")
return
end
unless available_roles_for_impersonation.include?(role)
redirect_back fallback_location: "/", allow_other_host: false, alert: I18n.t("lcp_ruby.impersonation.invalid_role", role: role, default: "Role '%{role}' is not a valid role.")
return
end
session[:lcp_impersonate_role] = role
redirect_back fallback_location: "/", allow_other_host: false, notice: I18n.t("lcp_ruby.impersonation.started", role: role, default: "Impersonating role: %{role}")
end
|