Sha256: 5e608252bbe757efa9fc24bf64c7cad25ca104342bafb4e4161556ccb202e3e3

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

module SimpleAuth
  # Add a shortcut to SimpleAuth::Config
  def self.setup(&block)
    yield SimpleAuth::Config if block_given?
  end

  class Config
    # Automatically remove all session values that start with your model name.
    #
    # When an existing session is destroyed or a new session is created,
    # SimpleAuth will remove the record id stored as <tt>#{SimpleAuth::Config.model}</tt>.
    #
    # Additionally, you can enable this option to remove any other key composed by
    # <tt>#{SimpleAuth::Config.model}_*</tt>.
    #
    cattr_accessor :wipeout_session
    @@wipeout_session = false

    # Set which attributes will be used for authentication.
    cattr_accessor :credentials
    @@credentials = [:email, :login]

    # Set the user model
    cattr_accessor :model
    @@model = :user

    # Set the current controller object
    cattr_accessor :controller
    @@controller = nil

    # Set the login url
    cattr_accessor :login_url
    @@login_url = proc { login_path }

    # Logged users will be redirect to this url
    # when +redirect_logged_user+ helper is used.
    cattr_accessor :logged_url
    @@logged_url = proc { dashboard_path }

    def self.model_class
      model.to_s.classify.constantize
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_auth-2.0.4 lib/simple_auth/config.rb
simple_auth-2.0.3 lib/simple_auth/config.rb
simple_auth-2.0.2 lib/simple_auth/config.rb
simple_auth-2.0.1 lib/simple_auth/config.rb
simple_auth-2.0.0 lib/simple_auth/config.rb