Sha256: acc601a4c8ffcb23162f73612b41e4debfdc4ae549a682c5fcecf6ef07c7a54c

Contents?: true

Size: 934 Bytes

Versions: 4

Compression:

Stored size: 934 Bytes

Contents

module Brightcontent
  class ApplicationController < ActionController::Base
    add_flash_types :success, :info, :warning, :danger
    before_action :authorize
    before_action :set_locale
    helper TranslationHelper
    protect_from_forgery

    def index
      redirect_to polymorphic_url(user_resources.first.klass)
    end

    def default_url_options(options = {})
      { locale: I18n.locale }.merge options
    end

    private

    def set_locale
      I18n.locale = params[:locale] || Brightcontent.locale
    end

    def current_user
      @current_user ||= begin
        Brightcontent.user_model.find(session[:brightcontent_user_id]) if session[:brightcontent_user_id]
      end
    end
    helper_method :current_user

    def user_resources
      @user_resources ||= @current_user.resources
    end
    helper_method :user_resources

    def authorize
      redirect_to login_url unless current_user
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brightcontent-core-2.4.6 app/controllers/brightcontent/application_controller.rb
brightcontent-core-2.4.5 app/controllers/brightcontent/application_controller.rb
brightcontent-core-2.4.4 app/controllers/brightcontent/application_controller.rb
brightcontent-core-2.4.3 app/controllers/brightcontent/application_controller.rb