Class: Monban::Configuration
- Inherits:
-
Object
- Object
- Monban::Configuration
- Defined in:
- lib/monban/configuration.rb
Overview
Configuration options for Monban
Instance Attribute Summary collapse
- #authentication_service ⇒ Object
- #authentication_strategy ⇒ Object
- #creation_method ⇒ Object
- #failure_app ⇒ Object
- #find_method ⇒ Object
- #hashing_method ⇒ Object
- #no_login_handler ⇒ Object
- #no_login_redirect ⇒ Object
- #param_transformations ⇒ Object
- #password_reset_service ⇒ Object
- #sign_in_notice ⇒ Object
- #sign_in_service ⇒ Object
- #sign_out_service ⇒ Object
- #sign_up_service ⇒ Object
- #token_comparison ⇒ Object
-
#user_class ⇒ Object
User class.
- #user_lookup_field ⇒ Object
- #user_token_field ⇒ Object
- #user_token_store_field ⇒ Object
- #warden_serialize_from_session ⇒ Object
- #warden_serialize_into_session ⇒ Object
Instance Method Summary collapse
-
#default_creation_method ⇒ Object
Default creation method.
-
#default_find_method ⇒ Object
Default find method.
-
#default_hashing_method ⇒ Object
Default hashing method.
-
#default_no_login_handler ⇒ Object
Default handler when user is not logged in.
-
#default_token_comparison ⇒ Object
Default token comparison method.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 25 26 |
# File 'lib/monban/configuration.rb', line 19 def initialize setup_class_defaults setup_token_hashing setup_notices setup_services setup_warden setup_param_transformations end |
Instance Attribute Details
#authentication_service ⇒ Object
9 10 11 |
# File 'lib/monban/configuration.rb', line 9 def authentication_service @authentication_service end |
#authentication_strategy ⇒ Object
13 14 15 |
# File 'lib/monban/configuration.rb', line 13 def authentication_strategy @authentication_strategy end |
#creation_method ⇒ Object
11 12 13 |
# File 'lib/monban/configuration.rb', line 11 def creation_method @creation_method end |
#failure_app ⇒ Object
10 11 12 |
# File 'lib/monban/configuration.rb', line 10 def failure_app @failure_app end |
#find_method ⇒ Object
11 12 13 |
# File 'lib/monban/configuration.rb', line 11 def find_method @find_method end |
#hashing_method ⇒ Object
6 7 8 |
# File 'lib/monban/configuration.rb', line 6 def hashing_method @hashing_method end |
#no_login_handler ⇒ Object
12 13 14 |
# File 'lib/monban/configuration.rb', line 12 def no_login_handler @no_login_handler end |
#no_login_redirect ⇒ Object
12 13 14 |
# File 'lib/monban/configuration.rb', line 12 def no_login_redirect @no_login_redirect end |
#param_transformations ⇒ Object
15 16 17 |
# File 'lib/monban/configuration.rb', line 15 def param_transformations @param_transformations end |
#password_reset_service ⇒ Object
9 10 11 |
# File 'lib/monban/configuration.rb', line 9 def password_reset_service @password_reset_service end |
#sign_in_notice ⇒ Object
7 8 9 |
# File 'lib/monban/configuration.rb', line 7 def sign_in_notice @sign_in_notice end |
#sign_in_service ⇒ Object
8 9 10 |
# File 'lib/monban/configuration.rb', line 8 def sign_in_service @sign_in_service end |
#sign_out_service ⇒ Object
8 9 10 |
# File 'lib/monban/configuration.rb', line 8 def sign_out_service @sign_out_service end |
#sign_up_service ⇒ Object
8 9 10 |
# File 'lib/monban/configuration.rb', line 8 def sign_up_service @sign_up_service end |
#token_comparison ⇒ Object
6 7 8 |
# File 'lib/monban/configuration.rb', line 6 def token_comparison @token_comparison end |
#user_class ⇒ Object
User class. Can be overriden via Monban.configure
94 95 96 |
# File 'lib/monban/configuration.rb', line 94 def user_class @user_class.constantize end |
#user_lookup_field ⇒ Object
6 7 8 |
# File 'lib/monban/configuration.rb', line 6 def user_lookup_field @user_lookup_field end |
#user_token_field ⇒ Object
5 6 7 |
# File 'lib/monban/configuration.rb', line 5 def user_token_field @user_token_field end |
#user_token_store_field ⇒ Object
5 6 7 |
# File 'lib/monban/configuration.rb', line 5 def user_token_store_field @user_token_store_field end |
#warden_serialize_from_session ⇒ Object
14 15 16 |
# File 'lib/monban/configuration.rb', line 14 def warden_serialize_from_session @warden_serialize_from_session end |
#warden_serialize_into_session ⇒ Object
14 15 16 |
# File 'lib/monban/configuration.rb', line 14 def warden_serialize_into_session @warden_serialize_into_session end |
Instance Method Details
#default_creation_method ⇒ Object
Default creation method. Can be overriden via Monban.configure
31 32 33 34 35 36 |
# File 'lib/monban/configuration.rb', line 31 def default_creation_method ->(params) do updated_params = Monban.transform_params(params) Monban.config.user_class.create(updated_params) end end |
#default_find_method ⇒ Object
Default find method. Can be overriden via Monban.configure
55 56 57 58 59 60 |
# File 'lib/monban/configuration.rb', line 55 def default_find_method ->(params) do updated_params = Monban.transform_params(params) Monban.config.user_class.find_by(updated_params) end end |
#default_hashing_method ⇒ Object
Default hashing method. Can be overriden via Monban.configure
41 42 43 44 45 46 47 48 49 |
# File 'lib/monban/configuration.rb', line 41 def default_hashing_method ->(token) do if token.present? BCrypt::Password.create(token) else token end end end |
#default_no_login_handler ⇒ Object
Default handler when user is not logged in. Can be overriden via Monban.configure
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/monban/configuration.rb', line 76 def default_no_login_handler ->(controller) do notice = Monban.config.sign_in_notice if notice.respond_to?(:call) controller.flash.notice = notice.call else warn "[DEPRECATION] `Monban.config.sign_in_notice` should be a lambda instead of a string" controller.flash.notice = notice end controller.redirect_to Monban.config.no_login_redirect end end |
#default_token_comparison ⇒ Object
Default token comparison method. Can be overriden via Monban.configure
65 66 67 68 69 |
# File 'lib/monban/configuration.rb', line 65 def default_token_comparison ->(digest, undigested_token) do BCrypt::Password.new(digest) == undigested_token end end |