Sha256: 1514d425658aeb1329de62975d21a69eaffef45d2db45c5a9dd01b7cfd70def5

Contents?: true

Size: 993 Bytes

Versions: 13

Compression:

Stored size: 993 Bytes

Contents

class Admin::BaseController < ActionController::Base

  include Admin::Hooks
  include Typus::Authentication::const_get(Typus.authentication.to_s.classify)

  before_filter :verify_remote_ip, :reload_config_and_roles, :authenticate, :set_locale

  helper_method :admin_user, :current_role

  protected

  def verify_remote_ip
    if !request.local? && Typus.ip_whitelist.any?
      unless Typus.ip_whitelist.include?(request.ip)
        render :text => "IP not in our whitelist."
      end
    end
  end

  def reload_config_and_roles
    Typus.reload! if Rails.env.development?
  end

  def set_locale
    I18n.locale = if admin_user && admin_user.respond_to?(:locale)
      admin_user.locale
    else
      Typus::I18n.default_locale
    end
  end

  def zero_users
    Typus.user_class.count.zero?
  end

  def not_allowed(reason = 'Not allowed!')
    render :text => reason, :status => :unprocessable_entity
  end

  def admin_user_params
    params[Typus.user_class_as_symbol]
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
brainsome_typus-4.0.0.beta13 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta12 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta11 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta10 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta9 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta8 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta7 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta6 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta5 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta4 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta3 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta2 app/controllers/admin/base_controller.rb
brainsome_typus-4.0.0.beta1 app/controllers/admin/base_controller.rb