Module: EgovUtils::UserUtils::ApplicationControllerPatch
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/egov_utils/user_utils/application_controller_patch.rb
Instance Method Summary collapse
- #current_user ⇒ Object
- #editable_attributes(model, action = :update) ⇒ Object
- #editable_attributes_for(entity, action = :update) ⇒ Object
- #internal_network? ⇒ Boolean
- #mailer_host ⇒ Object
- #redirect_back(fallback_location:, **args) ⇒ Object
- #render_404(exception = nil) ⇒ Object
- #render_modal_js(**options) ⇒ Object
- #user_setup ⇒ Object
Instance Method Details
#current_user ⇒ Object
28 29 30 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 28 def current_user User.current || user_setup end |
#editable_attributes(model, action = :update) ⇒ Object
65 66 67 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 65 def editable_attributes(model, action=:update) EgovUtils::ModelPermissions.build(model, current_ability).editable_attributes(action) end |
#editable_attributes_for(entity, action = :update) ⇒ Object
69 70 71 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 69 def editable_attributes_for(entity, action=:update) EgovUtils::ModelPermissions.build(entity.type, current_ability).editable_attributes_for(entity, action) end |
#internal_network? ⇒ Boolean
24 25 26 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 24 def internal_network? request.host.ends_with? 'servis.justice.cz' end |
#mailer_host ⇒ Object
32 33 34 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 32 def mailer_host request.protocol + request.host_with_port end |
#redirect_back(fallback_location:, **args) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 43 def redirect_back(fallback_location:, **args) if params[:back_url] redirect_to URI.parse(params[:back_url]) else super end end |
#render_404(exception = nil) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 57 def render_404(exception = nil) respond_to do |format| format.json { head :not_found, content_type: 'text/html' } format.html { render template: "errors/error_404", error: exception.try('message'), status: 404 } format.js { head :not_found, content_type: 'text/html' } end end |
#render_modal_js(**options) ⇒ Object
51 52 53 54 55 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 51 def render_modal_js(**) @partial_scope = [:scope] || params[:controller] @action = [:action] || params[:action] render 'common/modal_action' end |
#user_setup ⇒ Object
36 37 38 39 40 41 |
# File 'lib/egov_utils/user_utils/application_controller_patch.rb', line 36 def user_setup # Find the current user User.current = find_current_user || find_kerberos_user || User.anonymous logger.info(" Current user: " + (User.current.logged? ? "#{User.current.login} (id=#{User.current.id})(roles=#{User.current.all_role_names.join(',')})" : "anonymous")) if logger User.current end |