Sha256: 024f72e218b9019dc2a7bf752d7028d706cb7e58433a9234b37874f8da8bb243

Contents?: true

Size: 950 Bytes

Versions: 22

Compression:

Stored size: 950 Bytes

Contents

module CMS
  module Authenticate
    extend ActiveSupport::Concern

    included do
      http_basic_authenticate_with name: '<%= app_name %>', password: '<%= SecureRandom.hex %>' if Rails.env.staging?

      helper_method :current_user, :current_user?, :current_admin, :current_admin?
    end

    def current_user
<% if options.solidus? -%>
      @current_user ||= spree_current_user
<% else -%>
      # TODO: override or rewrite
      @current_user ||= Struct.new(:admin?).new(true)
<% end -%>
    end

    def current_user?
      return @is_current_user if defined? @is_current_user
      @is_current_user = !!current_user
    end

    def current_admin
      current_user if current_admin?
    end

    def current_admin?
      return @is_current_admin if defined? @is_current_admin
      @is_current_admin = !!current_user.try(:admin?)
    end

    def authenticate_admin_user!
      raise SecurityError unless current_admin?
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
o2webappizer-0.2.6 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.2.5 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.2.4 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.2.3 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.2.2 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.2.1 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.2.0 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.15 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.14 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.13 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.12 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.11 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.10 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.9 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.8 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.7 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.6 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.5 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.4 templates/app/controllers/cms/authenticate.rb.tt
o2webappizer-0.1.3 templates/app/controllers/cms/authenticate.rb.tt