Module: EasyAuth
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/easy_auth.rb,
lib/easy_auth/engine.rb,
lib/easy_auth/version.rb,
lib/generators/easy_auth/setup_generator.rb
Defined Under Namespace
Modules: Controllers, Helpers, Mailers, Models, Routes, TokenGenerator Classes: Engine, SetupGenerator
Constant Summary collapse
- VERSION =
'0.3.2'
Class Method Summary collapse
-
.account_model ⇒ Class
The assumed account class.
-
.authenticate(controller) ⇒ Object
Main authenticate method to delegate to the proper identity’s .authenticate method Should handle any redirects necessary.
-
.config(&block) {|_self| ... } ⇒ Object
EasyAuth config.
-
.find_identity_model(params) ⇒ Class
Find the proper identity model Will use params to first see if the identity’s model method exists:.
-
.identity_model ⇒ Class
The top-level model that should be inherited from to build EasyAuth identities.
-
.new_session(controller) ⇒ Object
Main new_session method to delegate to the proper identity’s .new_session method Should handle any redirects necessary.
Class Method Details
.account_model ⇒ Class
The assumed account class
26 27 28 |
# File 'lib/easy_auth.rb', line 26 def self.account_model User end |
.authenticate(controller) ⇒ Object
Main authenticate method to delegate to the proper identity’s .authenticate method Should handle any redirects necessary
34 35 36 37 38 |
# File 'lib/easy_auth.rb', line 34 def self.authenticate(controller) if identity_model = find_identity_model(controller.params) identity_model.authenticate(controller) end end |
.config(&block) {|_self| ... } ⇒ Object
EasyAuth config
52 53 54 |
# File 'lib/easy_auth.rb', line 52 def self.config(&block) yield self end |
.find_identity_model(params) ⇒ Class
Find the proper identity model Will use params to first see if the identity’s model method exists:
i.e. password_identity_model
If that method doesn’t exist, will see if ‘Identities::#camelcased_identity_name` is defined
If that fails will finally check to see if the camelcased identity name exists in the top-leve namespace
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/easy_auth.rb', line 67 def self.find_identity_model(params) method_name = "#{params[:identity]}_identity_model" camelcased_identity_name = params[:identity].to_s.camelcase if respond_to?(method_name) send(method_name, params) elsif eval("::Identities::#{camelcased_identity_name} rescue nil") eval("::Identities::#{camelcased_identity_name}") else camelcased_identity_name.constantize end end |
.identity_model ⇒ Class
The top-level model that should be inherited from to build EasyAuth identities
19 20 21 |
# File 'lib/easy_auth.rb', line 19 def self.identity_model ::Identity end |
.new_session(controller) ⇒ Object
Main new_session method to delegate to the proper identity’s .new_session method Should handle any redirects necessary
44 45 46 47 |
# File 'lib/easy_auth.rb', line 44 def self.new_session(controller) identity_model = find_identity_model(controller.params) identity_model.new_session(controller) end |