Sha256: a95fd72647928ad9f719c06ce9e0db40378383d6d769ffd2b9c2ec353cb96be3

Contents?: true

Size: 766 Bytes

Versions: 11

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true

module MrCommon
  class BaseController < MrCommon.base_controller_class
    layout "layouts/mr_common/layout"
    helper BadgeHelper

    before_action MrCommon.authentication_method_name if MrCommon.authentication_method_name.present?
    before_action :authorize_user if MrCommon.current_user_authorization_method_name.present?

    private

      def authorize_user
        user = send MrCommon.current_user_method_name
        authorized = user.send MrCommon.current_user_authorization_method_name
        redirect_to main_app.root_path, alert: "Not authorized" unless authorized
      end

      def render_not_found
        render file: File.join(Rails.root, "public", "404.html"), layout: false, status: 404
      end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mr_common-2.1.0 app/controllers/mr_common/base_controller.rb
mr_common-2.0.0 app/controllers/mr_common/base_controller.rb
mr_common-1.3.0 app/controllers/mr_common/base_controller.rb
mr_common-1.2.0 app/controllers/mr_common/base_controller.rb
mr_common-1.1.0 app/controllers/mr_common/base_controller.rb
mr_common-1.0.5 app/controllers/mr_common/base_controller.rb
mr_common-1.0.4 app/controllers/mr_common/base_controller.rb
mr_common-1.0.3 app/controllers/mr_common/base_controller.rb
mr_common-1.0.2 app/controllers/mr_common/base_controller.rb
mr_common-1.0.1 app/controllers/mr_common/base_controller.rb
mr_common-1.0.0 app/controllers/mr_common/base_controller.rb