Sha256: 78f3bea682a7b47a17406a173e4d4983e84db8c619da4bc4af1f5f52560e6397

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

# Provides authentication accessors.
#
# Alchemy has some defaults for user model name and login logout path names:
#
# +Alchemy.user_class_name+ defaults to +'User'+
# +Alchemy.login_path defaults to +'/login'+
# +Alchemy.logout_path defaults to +'/admin/logout'+
#
# Anyway, you can tell Alchemy about your authentication model configuration:
#
#   1. Your user class name - @see: Alchemy.user_class
#   2. The path to the login form - @see: Alchemy.login_path
#   3. The path to the logout method - @see: Alchemy.logout_path
#
# == Example
#
#     # config/initializers/alchemy.rb
#     Alchemy.user_class_name = 'Admin'
#     Alchemy.login_path = '/auth/login'
#     Alchemy.logout_path = '/auth/logout'
#
# If you don't have your own user model or don't want to provide one,
# add the `alchemy-devise` gem into your App's Gemfile.
#
module Alchemy
  mattr_accessor :user_class_name, :login_path, :logout_path

  # Defaults
  #
  @@user_class_name = 'User'
  @@login_path = '/login'
  @@logout_path = '/logout'

  # Returns the user class
  #
  # Set your App's user class to Alchemy.user_class_name in an initializer.
  #
  # Defaults to +User+
  #
  # == Example
  #
  #     # config/initializers/alchemy.rb
  #     Alchemy.user_class_name = 'Admin'
  #
  def self.user_class
    @@user_class ||= begin
      if @@user_class_name.is_a?(String)
        @@user_class_name.constantize
      else
        raise 'Alchemy.user_class_name must be a String, not a Class.'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alchemy_cms-2.9.1 lib/alchemy/auth_accessors.rb
alchemy_cms-2.9.0 lib/alchemy/auth_accessors.rb