Sha256: f2cf805e7c6a592ec39b1f9c30a41a6f8889ecfad0f18445f902d4835c544c60

Contents?: true

Size: 708 Bytes

Versions: 5

Compression:

Stored size: 708 Bytes

Contents

module BulutfonDashboard
  class ApplicationController < BaseController

    protect_from_forgery with: :exception
    before_action :check_current_user, :set_bulutfon
    layout BulutfonDashboard.layout || 'application'

    private
    def check_current_user
      @current_user = BulutfonDashboard.current_user
      unless @current_user.present?
        redirect_to main_app.root_path
        return
      end
    end

    def set_bulutfon
      @token = BulutfonDashboard::BulutfonUser.find_by(user_id: @current_user.id)

      unless @token.present?
        redirect_to bulutfon_users_path
        return
      end

      @bulutfon = BulutfonSDK::REST::Bulutfon.new(@token.api_token)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bulutfon_dashboard-0.7.4 app/controllers/bulutfon_dashboard/application_controller.rb
bulutfon_dashboard-0.7.3 app/controllers/bulutfon_dashboard/application_controller.rb
bulutfon_dashboard-0.7.2 app/controllers/bulutfon_dashboard/application_controller.rb
bulutfon_dashboard-0.7.1 app/controllers/bulutfon_dashboard/application_controller.rb
bulutfon_dashboard-0.7.0 app/controllers/bulutfon_dashboard/application_controller.rb