lib/simple_auth/config.rb in simple_auth-2.0.4 vs lib/simple_auth/config.rb in simple_auth-3.0.0
- old
+ new
@@ -1,44 +1,21 @@
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 scopes will be activated.
+ # By default it enables `user` and `admin`.
+ attr_accessor :scopes
- # Set which attributes will be used for authentication.
- cattr_accessor :credentials
- @@credentials = [:email, :login]
+ # Set the login url.
+ # This will be used to redirect unlogged users to the login page.
+ # Default to `login_path`.
+ attr_accessor :login_url
- # Set the user model
- cattr_accessor :model
- @@model = :user
+ # Set the logged url.
+ # This will be used to redirect logged users to the dashboard page.
+ # Default to `dashboard_path`.
+ attr_accessor :logged_url
- # 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
+ def install_helpers!
+ ::ActionController::Base.include SimpleAuth::ActionController
end
end
end