Sha256: 88e456220aa0bebd933a2a16323d76aff84f5af66c9c8e95714eba5a4ed1ed1e

Contents?: true

Size: 769 Bytes

Versions: 4

Compression:

Stored size: 769 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

4 entries across 4 versions & 1 rubygems

Version Path
rocketjob_mission_control-4.3.0 app/controllers/rocket_job_mission_control/application_controller.rb
rocketjob_mission_control-4.2.1 app/controllers/rocket_job_mission_control/application_controller.rb
rocketjob_mission_control-4.2.0 app/controllers/rocket_job_mission_control/application_controller.rb
rocketjob_mission_control-4.1.0 app/controllers/rocket_job_mission_control/application_controller.rb