Class: Monban::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/monban/configuration.rb

Overview

Configuration options for Monban

Since:

  • 0.0.15

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.

Since:

  • 0.0.15



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_serviceObject

Since:

  • 0.0.15



9
10
11
# File 'lib/monban/configuration.rb', line 9

def authentication_service
  @authentication_service
end

#authentication_strategyObject

Since:

  • 0.0.15



13
14
15
# File 'lib/monban/configuration.rb', line 13

def authentication_strategy
  @authentication_strategy
end

#creation_methodObject

Since:

  • 0.0.15



11
12
13
# File 'lib/monban/configuration.rb', line 11

def creation_method
  @creation_method
end

#failure_appObject

Since:

  • 0.0.15



10
11
12
# File 'lib/monban/configuration.rb', line 10

def failure_app
  @failure_app
end

#find_methodObject

Since:

  • 0.0.15



11
12
13
# File 'lib/monban/configuration.rb', line 11

def find_method
  @find_method
end

#hashing_methodObject

Since:

  • 0.0.15



6
7
8
# File 'lib/monban/configuration.rb', line 6

def hashing_method
  @hashing_method
end

#no_login_handlerObject

Since:

  • 0.0.15



12
13
14
# File 'lib/monban/configuration.rb', line 12

def 
  @no_login_handler
end

#no_login_redirectObject

Since:

  • 0.0.15



12
13
14
# File 'lib/monban/configuration.rb', line 12

def 
  @no_login_redirect
end

#param_transformationsObject

Since:

  • 0.0.15



15
16
17
# File 'lib/monban/configuration.rb', line 15

def param_transformations
  @param_transformations
end

#password_reset_serviceObject

Since:

  • 0.0.15



9
10
11
# File 'lib/monban/configuration.rb', line 9

def password_reset_service
  @password_reset_service
end

#sign_in_noticeObject

Since:

  • 0.0.15



7
8
9
# File 'lib/monban/configuration.rb', line 7

def 
  @sign_in_notice
end

#sign_in_serviceObject

Since:

  • 0.0.15



8
9
10
# File 'lib/monban/configuration.rb', line 8

def 
  @sign_in_service
end

#sign_out_serviceObject

Since:

  • 0.0.15



8
9
10
# File 'lib/monban/configuration.rb', line 8

def sign_out_service
  @sign_out_service
end

#sign_up_serviceObject

Since:

  • 0.0.15



8
9
10
# File 'lib/monban/configuration.rb', line 8

def 
  @sign_up_service
end

#token_comparisonObject

Since:

  • 0.0.15



6
7
8
# File 'lib/monban/configuration.rb', line 6

def token_comparison
  @token_comparison
end

#user_classObject

User class. Can be overriden via Monban.configure

See Also:

Since:

  • 0.0.15



94
95
96
# File 'lib/monban/configuration.rb', line 94

def user_class
  @user_class.constantize
end

#user_lookup_fieldObject

Since:

  • 0.0.15



6
7
8
# File 'lib/monban/configuration.rb', line 6

def user_lookup_field
  @user_lookup_field
end

#user_token_fieldObject

Since:

  • 0.0.15



5
6
7
# File 'lib/monban/configuration.rb', line 5

def user_token_field
  @user_token_field
end

#user_token_store_fieldObject

Since:

  • 0.0.15



5
6
7
# File 'lib/monban/configuration.rb', line 5

def user_token_store_field
  @user_token_store_field
end

#warden_serialize_from_sessionObject

Since:

  • 0.0.15



14
15
16
# File 'lib/monban/configuration.rb', line 14

def warden_serialize_from_session
  @warden_serialize_from_session
end

#warden_serialize_into_sessionObject

Since:

  • 0.0.15



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_methodObject

Default creation method. Can be overriden via Monban.configure

See Also:

Since:

  • 0.0.15



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_methodObject

Default find method. Can be overriden via Monban.configure

See Also:

Since:

  • 0.0.15



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_methodObject

Default hashing method. Can be overriden via Monban.configure

See Also:

Since:

  • 0.0.15



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_handlerObject

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 
  ->(controller) do
    notice = Monban.config.

    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.
  end
end

#default_token_comparisonObject

Default token comparison method. Can be overriden via Monban.configure

See Also:

Since:

  • 0.0.15



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