Sha256: e6cd1246c7f237a392dd197fbfa4fd41a31730607398e9c5c964fa699ddd6e54

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

module RocketJobMissionControl
  class ApplicationController < ActionController::Base
    protect_from_forgery with: :exception

    around_action :with_time_zone

    private

    def with_time_zone(&block)
      if time_zone = session["time_zone"] || "UTC"
        Time.use_zone(time_zone, &block)
      end
    end

    def current_policy
      @current_policy ||= begin
        @args =
          if Config.authorization_callback
            instance_exec(&Config.authorization_callback)
          else
            {roles: %i[admin]}
          end
        AccessPolicy.new(Authorization.new(@args))
      end
    end

    def login
      @login ||= begin
        args = instance_exec(&Config.authorization_callback)
        args[:login]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rocketjob_mission_control-5.0.0 app/controllers/rocket_job_mission_control/application_controller.rb
rocketjob_mission_control-5.0.0.beta1 app/controllers/rocket_job_mission_control/application_controller.rb