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