authlogic 4.5.0 → 6.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/lib/authlogic/acts_as_authentic/base.rb +19 -19
  3. data/lib/authlogic/acts_as_authentic/email.rb +3 -170
  4. data/lib/authlogic/acts_as_authentic/logged_in_status.rb +3 -1
  5. data/lib/authlogic/acts_as_authentic/login.rb +7 -174
  6. data/lib/authlogic/acts_as_authentic/magic_columns.rb +7 -4
  7. data/lib/authlogic/acts_as_authentic/password.rb +67 -256
  8. data/lib/authlogic/acts_as_authentic/perishable_token.rb +8 -5
  9. data/lib/authlogic/acts_as_authentic/persistence_token.rb +10 -4
  10. data/lib/authlogic/acts_as_authentic/queries/case_sensitivity.rb +53 -0
  11. data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +36 -20
  12. data/lib/authlogic/acts_as_authentic/session_maintenance.rb +12 -8
  13. data/lib/authlogic/acts_as_authentic/single_access_token.rb +10 -8
  14. data/lib/authlogic/config.rb +9 -1
  15. data/lib/authlogic/controller_adapters/abstract_adapter.rb +28 -4
  16. data/lib/authlogic/controller_adapters/rack_adapter.rb +2 -0
  17. data/lib/authlogic/controller_adapters/rails_adapter.rb +7 -30
  18. data/lib/authlogic/controller_adapters/sinatra_adapter.rb +6 -0
  19. data/lib/authlogic/cookie_credentials.rb +63 -0
  20. data/lib/authlogic/crypto_providers/bcrypt.rb +3 -3
  21. data/lib/authlogic/crypto_providers/md5/v2.rb +35 -0
  22. data/lib/authlogic/crypto_providers/md5.rb +6 -6
  23. data/lib/authlogic/crypto_providers/scrypt.rb +2 -0
  24. data/lib/authlogic/crypto_providers/sha1/v2.rb +41 -0
  25. data/lib/authlogic/crypto_providers/sha1.rb +7 -6
  26. data/lib/authlogic/crypto_providers/sha256/v2.rb +58 -0
  27. data/lib/authlogic/crypto_providers/sha256.rb +5 -0
  28. data/lib/authlogic/crypto_providers/sha512/v2.rb +39 -0
  29. data/lib/authlogic/crypto_providers/sha512.rb +9 -5
  30. data/lib/authlogic/crypto_providers.rb +5 -20
  31. data/lib/authlogic/errors.rb +50 -0
  32. data/lib/authlogic/i18n/translator.rb +4 -1
  33. data/lib/authlogic/i18n.rb +3 -1
  34. data/lib/authlogic/random.rb +2 -0
  35. data/lib/authlogic/session/base.rb +2197 -39
  36. data/lib/authlogic/session/magic_column/assigns_last_request_at.rb +46 -0
  37. data/lib/authlogic/test_case/mock_api_controller.rb +52 -0
  38. data/lib/authlogic/test_case/mock_controller.rb +3 -1
  39. data/lib/authlogic/test_case/mock_cookie_jar.rb +32 -6
  40. data/lib/authlogic/test_case/mock_logger.rb +2 -0
  41. data/lib/authlogic/test_case/mock_request.rb +12 -0
  42. data/lib/authlogic/test_case/rails_request_adapter.rb +9 -1
  43. data/lib/authlogic/test_case.rb +5 -0
  44. data/lib/authlogic/version.rb +2 -1
  45. data/lib/authlogic.rb +5 -28
  46. metadata +175 -200
  47. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
  48. data/.github/ISSUE_TEMPLATE/feature_proposal.md +0 -32
  49. data/.github/triage.md +0 -86
  50. data/.gitignore +0 -15
  51. data/.rubocop.yml +0 -133
  52. data/.rubocop_todo.yml +0 -74
  53. data/.travis.yml +0 -24
  54. data/CHANGELOG.md +0 -348
  55. data/CONTRIBUTING.md +0 -91
  56. data/Gemfile +0 -6
  57. data/LICENSE +0 -20
  58. data/README.md +0 -448
  59. data/Rakefile +0 -21
  60. data/UPGRADING.md +0 -22
  61. data/authlogic.gemspec +0 -40
  62. data/doc/use_normal_rails_validation.md +0 -82
  63. data/gemfiles/Gemfile.rails-4.2.x +0 -6
  64. data/gemfiles/Gemfile.rails-5.1.x +0 -6
  65. data/gemfiles/Gemfile.rails-5.2.x +0 -6
  66. data/lib/authlogic/acts_as_authentic/restful_authentication.rb +0 -106
  67. data/lib/authlogic/acts_as_authentic/validations_scope.rb +0 -35
  68. data/lib/authlogic/authenticates_many/association.rb +0 -50
  69. data/lib/authlogic/authenticates_many/base.rb +0 -81
  70. data/lib/authlogic/crypto_providers/aes256.rb +0 -71
  71. data/lib/authlogic/crypto_providers/wordpress.rb +0 -72
  72. data/lib/authlogic/regex.rb +0 -79
  73. data/lib/authlogic/session/activation.rb +0 -73
  74. data/lib/authlogic/session/active_record_trickery.rb +0 -65
  75. data/lib/authlogic/session/brute_force_protection.rb +0 -127
  76. data/lib/authlogic/session/callbacks.rb +0 -153
  77. data/lib/authlogic/session/cookies.rb +0 -329
  78. data/lib/authlogic/session/existence.rb +0 -103
  79. data/lib/authlogic/session/foundation.rb +0 -105
  80. data/lib/authlogic/session/http_auth.rb +0 -107
  81. data/lib/authlogic/session/id.rb +0 -53
  82. data/lib/authlogic/session/klass.rb +0 -73
  83. data/lib/authlogic/session/magic_columns.rb +0 -119
  84. data/lib/authlogic/session/magic_states.rb +0 -82
  85. data/lib/authlogic/session/params.rb +0 -130
  86. data/lib/authlogic/session/password.rb +0 -318
  87. data/lib/authlogic/session/perishable_token.rb +0 -24
  88. data/lib/authlogic/session/persistence.rb +0 -77
  89. data/lib/authlogic/session/priority_record.rb +0 -38
  90. data/lib/authlogic/session/scopes.rb +0 -138
  91. data/lib/authlogic/session/session.rb +0 -77
  92. data/lib/authlogic/session/timeout.rb +0 -103
  93. data/lib/authlogic/session/unauthorized_record.rb +0 -56
  94. data/lib/authlogic/session/validation.rb +0 -93
  95. data/test/acts_as_authentic_test/base_test.rb +0 -27
  96. data/test/acts_as_authentic_test/email_test.rb +0 -241
  97. data/test/acts_as_authentic_test/logged_in_status_test.rb +0 -64
  98. data/test/acts_as_authentic_test/login_test.rb +0 -153
  99. data/test/acts_as_authentic_test/magic_columns_test.rb +0 -29
  100. data/test/acts_as_authentic_test/password_test.rb +0 -263
  101. data/test/acts_as_authentic_test/perishable_token_test.rb +0 -98
  102. data/test/acts_as_authentic_test/persistence_token_test.rb +0 -62
  103. data/test/acts_as_authentic_test/restful_authentication_test.rb +0 -48
  104. data/test/acts_as_authentic_test/session_maintenance_test.rb +0 -150
  105. data/test/acts_as_authentic_test/single_access_test.rb +0 -46
  106. data/test/adapter_test.rb +0 -23
  107. data/test/authenticates_many_test.rb +0 -33
  108. data/test/config_test.rb +0 -38
  109. data/test/crypto_provider_test/aes256_test.rb +0 -16
  110. data/test/crypto_provider_test/bcrypt_test.rb +0 -16
  111. data/test/crypto_provider_test/scrypt_test.rb +0 -16
  112. data/test/crypto_provider_test/sha1_test.rb +0 -25
  113. data/test/crypto_provider_test/sha256_test.rb +0 -16
  114. data/test/crypto_provider_test/sha512_test.rb +0 -16
  115. data/test/crypto_provider_test/wordpress_test.rb +0 -26
  116. data/test/fixtures/companies.yml +0 -5
  117. data/test/fixtures/employees.yml +0 -17
  118. data/test/fixtures/projects.yml +0 -3
  119. data/test/fixtures/users.yml +0 -41
  120. data/test/i18n/lol.yml +0 -4
  121. data/test/i18n_test.rb +0 -35
  122. data/test/libs/affiliate.rb +0 -9
  123. data/test/libs/company.rb +0 -8
  124. data/test/libs/employee.rb +0 -9
  125. data/test/libs/employee_session.rb +0 -4
  126. data/test/libs/ldaper.rb +0 -5
  127. data/test/libs/project.rb +0 -5
  128. data/test/libs/user.rb +0 -9
  129. data/test/libs/user_session.rb +0 -27
  130. data/test/random_test.rb +0 -15
  131. data/test/session_test/activation_test.rb +0 -45
  132. data/test/session_test/active_record_trickery_test.rb +0 -78
  133. data/test/session_test/brute_force_protection_test.rb +0 -110
  134. data/test/session_test/callbacks_test.rb +0 -42
  135. data/test/session_test/cookies_test.rb +0 -244
  136. data/test/session_test/credentials_test.rb +0 -0
  137. data/test/session_test/existence_test.rb +0 -88
  138. data/test/session_test/foundation_test.rb +0 -24
  139. data/test/session_test/http_auth_test.rb +0 -60
  140. data/test/session_test/id_test.rb +0 -19
  141. data/test/session_test/klass_test.rb +0 -42
  142. data/test/session_test/magic_columns_test.rb +0 -62
  143. data/test/session_test/magic_states_test.rb +0 -60
  144. data/test/session_test/params_test.rb +0 -61
  145. data/test/session_test/password_test.rb +0 -107
  146. data/test/session_test/perishability_test.rb +0 -17
  147. data/test/session_test/persistence_test.rb +0 -35
  148. data/test/session_test/scopes_test.rb +0 -68
  149. data/test/session_test/session_test.rb +0 -80
  150. data/test/session_test/timeout_test.rb +0 -84
  151. data/test/session_test/unauthorized_record_test.rb +0 -15
  152. data/test/session_test/validation_test.rb +0 -25
  153. data/test/test_helper.rb +0 -272
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97762cbf5ee158d5a18ebe77bc96a542241f16b813ddda3ca80d2271dcbd0098
4
- data.tar.gz: 5a0bbb0e964b0d71f436dbabb729f6da9dddc83d5c3fd5bdd33dc003cc15097f
3
+ metadata.gz: b9fad0a99beb89fdac894ff1979b59459073fbf597d375b6749b263e86be930d
4
+ data.tar.gz: 4ea061519a7a881f78cfaddf1a86e312d082dba28ce22c51e52c38ac51c62581
5
5
  SHA512:
6
- metadata.gz: c4e860a5ca9a8ccd511f99d55a25ba3a17d800eec68e8c074c40a9b5c9f2a717d906c01660878bac030d72c4d058331e6230dfaa7145889202dd1b05a0d39ea8
7
- data.tar.gz: 88319378fcb41fdec36a2d35bd1b35f34d5459eb2f52d94469cfe47faf7613d4f0a4974d659d40df9812656270c8c916018e5dfb941f0699f11e7a3bf0c5de13
6
+ metadata.gz: db0557f858087739e3a292ab6ba63becbca9a0204874f2794e934e442c58fc6d7cf814450d9df4adc76c8d1e41d18f625fc7fa942df2810248aa7b9176aa60ee
7
+ data.tar.gz: 8c349c4e3a8579384c2e1b7f3fc2f85b2974e7871d02a9e9a93117f83777110e21ad57fa4f04493f8116aaba113ebd9f735cea7ff9ae8b02e73897a51b044593
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Authlogic
2
4
  module ActsAsAuthentic
3
5
  # Provides the base functionality for acts_as_authentic
@@ -28,20 +30,9 @@ module Authlogic
28
30
  # end
29
31
  #
30
32
  # See the various sub modules for the configuration they provide.
31
- def acts_as_authentic(unsupported_options = nil)
32
- # Stop all configuration if the DB is not set up
33
- return unless db_setup?
34
-
35
- unless unsupported_options.nil?
36
- raise ArgumentError.new(
37
- "You are using the old v1.X.X configuration method for " \
38
- "Authlogic. Instead of passing a hash of configuration " \
39
- "options to acts_as_authentic, pass a block: " \
40
- "acts_as_authentic { |c| c.my_option = my_value }"
41
- )
42
- end
43
-
33
+ def acts_as_authentic
44
34
  yield self if block_given?
35
+ return unless db_setup?
45
36
  acts_as_authentic_modules.each { |mod| include mod }
46
37
  end
47
38
 
@@ -74,12 +65,27 @@ module Authlogic
74
65
  self.acts_as_authentic_modules = modules
75
66
  end
76
67
 
68
+ # Some Authlogic modules requires a database connection with a existing
69
+ # users table by the moment when you call the `acts_as_authentic`
70
+ # method. If you try to call `acts_as_authentic` without a database
71
+ # connection, it will raise a `Authlogic::ModelSetupError`.
72
+ #
73
+ # If you rely on the User model before the database is setup correctly,
74
+ # set this field to false.
75
+ # * <tt>Default:</tt> false
76
+ # * <tt>Accepts:</tt> Boolean
77
+ def raise_on_model_setup_error(value = nil)
78
+ rw_config(:raise_on_model_setup_error, value, false)
79
+ end
80
+ alias raise_on_model_setup_error= raise_on_model_setup_error
81
+
77
82
  private
78
83
 
79
84
  def db_setup?
80
85
  column_names
81
86
  true
82
87
  rescue StandardError
88
+ raise ModelSetupError if raise_on_model_setup_error
83
89
  false
84
90
  end
85
91
 
@@ -106,11 +112,5 @@ end
106
112
  ::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::Password
107
113
  ::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::PerishableToken
108
114
  ::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::PersistenceToken
109
-
110
- # RestfulAuthentication is deprecated. See comments in
111
- # acts_as_authentic/restful_authentication.rb
112
- ::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::RestfulAuthentication
113
-
114
115
  ::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::SessionMaintenance
115
116
  ::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::SingleAccessToken
116
- ::ActiveRecord::Base.send :include, Authlogic::ActsAsAuthentic::ValidationsScope
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Authlogic
2
4
  module ActsAsAuthentic
3
5
  # Sometimes models won't have an explicit "login" or "username" field.
@@ -9,7 +11,6 @@ module Authlogic
9
11
  def self.included(klass)
10
12
  klass.class_eval do
11
13
  extend Config
12
- add_acts_as_authentic_module(Methods)
13
14
  end
14
15
  end
15
16
 
@@ -22,175 +23,7 @@ module Authlogic
22
23
  def email_field(value = nil)
23
24
  rw_config(:email_field, value, first_column_to_exist(nil, :email, :email_address))
24
25
  end
25
- alias_method :email_field=, :email_field
26
-
27
- # Toggles validating the email field or not.
28
- #
29
- # * <tt>Default:</tt> true
30
- # * <tt>Accepts:</tt> Boolean
31
- #
32
- # @deprecated
33
- def validate_email_field(value = nil)
34
- rw_config(:validate_email_field, value, true)
35
- end
36
- alias_method :validate_email_field=, :validate_email_field
37
-
38
- # A hash of options for the validates_length_of call for the email
39
- # field. Allows you to change this however you want.
40
- #
41
- # <b>Keep in mind this is ruby. I wanted to keep this as flexible as
42
- # possible, so you can completely replace the hash or merge options into
43
- # it. Checkout the convenience function
44
- # merge_validates_length_of_email_field_options to merge options.</b>
45
- #
46
- # * <tt>Default:</tt> {:maximum => 100}
47
- # * <tt>Accepts:</tt> Hash of options accepted by validates_length_of
48
- #
49
- # @deprecated
50
- def validates_length_of_email_field_options(value = nil)
51
- deprecate_authlogic_config("validates_length_of_email_field_options") if value
52
- rw_config(:validates_length_of_email_field_options, value, maximum: 100)
53
- end
54
- alias_method(
55
- :validates_length_of_email_field_options=,
56
- :validates_length_of_email_field_options
57
- )
58
-
59
- # A convenience function to merge options into the
60
- # validates_length_of_email_field_options. So instead of:
61
- #
62
- # self.validates_length_of_email_field_options =
63
- # validates_length_of_email_field_options.merge(:my_option => my_value)
64
- #
65
- # You can do this:
66
- #
67
- # merge_validates_length_of_email_field_options :my_option => my_value
68
- #
69
- # @deprecated
70
- def merge_validates_length_of_email_field_options(options = {})
71
- deprecate_authlogic_config("merge_validates_length_of_email_field_options")
72
- self.validates_length_of_email_field_options =
73
- validates_length_of_email_field_options.merge(options)
74
- end
75
-
76
- # A hash of options for the validates_format_of call for the email
77
- # field. Allows you to change this however you want.
78
- #
79
- # <b>Keep in mind this is ruby. I wanted to keep this as flexible as
80
- # possible, so you can completely replace the hash or merge options into
81
- # it. Checkout the convenience function
82
- # merge_validates_format_of_email_field_options to merge options.</b>
83
- #
84
- # To validate international email addresses, enable the provided
85
- # alternate regex:
86
- #
87
- # ```
88
- # validates_format_of_email_field_options(
89
- # with: Authlogic::Regex.email_nonascii
90
- # )
91
- # ```
92
- #
93
- # * <tt>Default:</tt>
94
- #
95
- # {
96
- # :with => Authlogic::Regex.email,
97
- # :message => Proc.new {
98
- # I18n.t(
99
- # 'error_messages.email_invalid',
100
- # :default => "should look like an email address."
101
- # )
102
- # }
103
- # }
104
- #
105
- # * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
106
- #
107
- # @deprecated
108
- def validates_format_of_email_field_options(value = nil)
109
- deprecate_authlogic_config("validates_format_of_email_field_options") if value
110
- rw_config(
111
- :validates_format_of_email_field_options,
112
- value,
113
- with: Authlogic::Regex::EMAIL,
114
- message: proc do
115
- I18n.t(
116
- "error_messages.email_invalid",
117
- default: "should look like an email address."
118
- )
119
- end
120
- )
121
- end
122
- alias_method(
123
- :validates_format_of_email_field_options=,
124
- :validates_format_of_email_field_options
125
- )
126
-
127
- # See merge_validates_length_of_email_field_options. The same thing
128
- # except for validates_format_of_email_field_options.
129
- #
130
- # @deprecated
131
- def merge_validates_format_of_email_field_options(options = {})
132
- deprecate_authlogic_config("merge_validates_format_of_email_field_options")
133
- self.validates_format_of_email_field_options =
134
- validates_format_of_email_field_options.merge(options)
135
- end
136
-
137
- # A hash of options for the validates_uniqueness_of call for the email
138
- # field. Allows you to change this however you want.
139
- #
140
- # <b>Keep in mind this is ruby. I wanted to keep this as flexible as
141
- # possible, so you can completely replace the hash or merge options into
142
- # it. Checkout the convenience function
143
- # merge_validates_uniqueness_of_email_field_options to merge
144
- # options.</b>
145
- #
146
- # * <tt>Default:</tt>
147
- #
148
- # {
149
- # :case_sensitive => false,
150
- # :scope => validations_scope,
151
- # :if => "#{email_field}_changed?".to_sym
152
- # }
153
- #
154
- # * <tt>Accepts:</tt> Hash of options accepted by validates_uniqueness_of
155
- #
156
- # @deprecated
157
- def validates_uniqueness_of_email_field_options(value = nil)
158
- deprecate_authlogic_config("validates_uniqueness_of_email_field_options") if value
159
- rw_config(
160
- :validates_uniqueness_of_email_field_options,
161
- value,
162
- case_sensitive: false,
163
- scope: validations_scope,
164
- if: "#{email_field}_changed?".to_sym
165
- )
166
- end
167
- alias_method(
168
- :validates_uniqueness_of_email_field_options=,
169
- :validates_uniqueness_of_email_field_options
170
- )
171
-
172
- # See merge_validates_length_of_email_field_options. The same thing
173
- # except for validates_uniqueness_of_email_field_options.
174
- #
175
- # @deprecated
176
- def merge_validates_uniqueness_of_email_field_options(options = {})
177
- deprecate_authlogic_config("merge_validates_uniqueness_of_email_field_options")
178
- self.validates_uniqueness_of_email_field_options =
179
- validates_uniqueness_of_email_field_options.merge(options)
180
- end
181
- end
182
-
183
- # All methods relating to the email field
184
- module Methods
185
- def self.included(klass)
186
- klass.class_eval do
187
- if validate_email_field && email_field
188
- validates_length_of email_field, validates_length_of_email_field_options
189
- validates_format_of email_field, validates_format_of_email_field_options
190
- validates_uniqueness_of email_field, validates_uniqueness_of_email_field_options
191
- end
192
- end
193
- end
26
+ alias email_field= email_field
194
27
  end
195
28
  end
196
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Authlogic
2
4
  module ActsAsAuthentic
3
5
  # Since web applications are stateless there is not sure fire way to tell if
@@ -22,7 +24,7 @@ module Authlogic
22
24
  def logged_in_timeout(value = nil)
23
25
  rw_config(:logged_in_timeout, (!value.nil? && value.to_i) || value, 10.minutes.to_i)
24
26
  end
25
- alias_method :logged_in_timeout=, :logged_in_timeout
27
+ alias logged_in_timeout= logged_in_timeout
26
28
  end
27
29
 
28
30
  # All methods for the logged in status feature seat.
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "authlogic/acts_as_authentic/queries/case_sensitivity"
1
4
  require "authlogic/acts_as_authentic/queries/find_with_case"
2
5
 
3
6
  module Authlogic
@@ -7,7 +10,6 @@ module Authlogic
7
10
  def self.included(klass)
8
11
  klass.class_eval do
9
12
  extend Config
10
- add_acts_as_authentic_module(Methods)
11
13
  end
12
14
  end
13
15
 
@@ -20,152 +22,7 @@ module Authlogic
20
22
  def login_field(value = nil)
21
23
  rw_config(:login_field, value, first_column_to_exist(nil, :login, :username))
22
24
  end
23
- alias_method :login_field=, :login_field
24
-
25
- # Whether or not to validate the login field
26
- #
27
- # * <tt>Default:</tt> true
28
- # * <tt>Accepts:</tt> Boolean
29
- #
30
- # @deprecated
31
- def validate_login_field(value = nil)
32
- rw_config(:validate_login_field, value, true)
33
- end
34
- alias_method :validate_login_field=, :validate_login_field
35
-
36
- # A hash of options for the validates_length_of call for the login
37
- # field. Allows you to change this however you want.
38
- #
39
- # <b>Keep in mind this is ruby. I wanted to keep this as flexible as
40
- # possible, so you can completely replace the hash or merge options into
41
- # it. Checkout the convenience function
42
- # merge_validates_length_of_login_field_options to merge options.</b>
43
- #
44
- # * <tt>Default:</tt> {:within => 3..100}
45
- # * <tt>Accepts:</tt> Hash of options accepted by validates_length_of
46
- #
47
- # @deprecated
48
- def validates_length_of_login_field_options(value = nil)
49
- deprecate_authlogic_config("validates_length_of_login_field_options") if value
50
- rw_config(:validates_length_of_login_field_options, value, within: 3..100)
51
- end
52
- alias_method(
53
- :validates_length_of_login_field_options=,
54
- :validates_length_of_login_field_options
55
- )
56
-
57
- # A convenience function to merge options into the
58
- # validates_length_of_login_field_options. So instead of:
59
- #
60
- # self.validates_length_of_login_field_options =
61
- # validates_length_of_login_field_options.merge(:my_option => my_value)
62
- #
63
- # You can do this:
64
- #
65
- # merge_validates_length_of_login_field_options :my_option => my_value
66
- #
67
- # @deprecated
68
- def merge_validates_length_of_login_field_options(options = {})
69
- deprecate_authlogic_config("merge_validates_length_of_login_field_options")
70
- self.validates_length_of_login_field_options =
71
- validates_length_of_login_field_options.merge(options)
72
- end
73
-
74
- # A hash of options for the validates_format_of call for the login
75
- # field. Allows you to change this however you want.
76
- #
77
- # <b>Keep in mind this is ruby. I wanted to keep this as flexible as
78
- # possible, so you can completely replace the hash or merge options into
79
- # it. Checkout the convenience function
80
- # merge_validates_format_of_login_field_options to merge options.</b>
81
- #
82
- # * <tt>Default:</tt>
83
- #
84
- # {
85
- # :with => Authlogic::Regex.login,
86
- # :message => lambda {
87
- # I18n.t(
88
- # 'error_messages.login_invalid',
89
- # :default => "should use only letters, numbers, spaces, and .-_@+ please."
90
- # )
91
- # }
92
- # }
93
- #
94
- # * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
95
- #
96
- # @deprecated
97
- def validates_format_of_login_field_options(value = nil)
98
- deprecate_authlogic_config("validates_format_of_login_field_options") if value
99
- rw_config(
100
- :validates_format_of_login_field_options,
101
- value,
102
- with: Authlogic::Regex::LOGIN,
103
- message: proc do
104
- I18n.t(
105
- "error_messages.login_invalid",
106
- default: "should use only letters, numbers, spaces, and .-_@+ please."
107
- )
108
- end
109
- )
110
- end
111
- alias_method(
112
- :validates_format_of_login_field_options=,
113
- :validates_format_of_login_field_options
114
- )
115
-
116
- # See merge_validates_length_of_login_field_options. The same thing,
117
- # except for validates_format_of_login_field_options
118
- #
119
- # @deprecated
120
- def merge_validates_format_of_login_field_options(options = {})
121
- deprecate_authlogic_config("merge_validates_format_of_login_field_options")
122
- self.validates_format_of_login_field_options =
123
- validates_format_of_login_field_options.merge(options)
124
- end
125
-
126
- # A hash of options for the validates_uniqueness_of call for the login
127
- # field. Allows you to change this however you want.
128
- #
129
- # <b>Keep in mind this is ruby. I wanted to keep this as flexible as
130
- # possible, so you can completely replace the hash or merge options into
131
- # it. Checkout the convenience function
132
- # merge_validates_format_of_login_field_options to merge options.</b>
133
- #
134
- # * <tt>Default:</tt>
135
- #
136
- # {
137
- # :case_sensitive => false,
138
- # :scope => validations_scope,
139
- # :if => "#{login_field}_changed?".to_sym
140
- # }
141
- #
142
- # * <tt>Accepts:</tt> Hash of options accepted by validates_uniqueness_of
143
- #
144
- # @deprecated
145
- def validates_uniqueness_of_login_field_options(value = nil)
146
- deprecate_authlogic_config("validates_uniqueness_of_login_field_options") if value
147
- rw_config(
148
- :validates_uniqueness_of_login_field_options,
149
- value,
150
- case_sensitive: false,
151
- scope: validations_scope,
152
- if: "#{login_field}_changed?".to_sym
153
- )
154
- end
155
- alias_method(
156
- :validates_uniqueness_of_login_field_options=,
157
- :validates_uniqueness_of_login_field_options
158
- )
159
-
160
- # See merge_validates_length_of_login_field_options. The same thing,
161
- # except for validates_uniqueness_of_login_field_options
162
- #
163
- # @deprecated
164
- def merge_validates_uniqueness_of_login_field_options(options = {})
165
- deprecate_authlogic_config("merge_validates_uniqueness_of_login_field_options")
166
- self.validates_uniqueness_of_login_field_options =
167
- validates_uniqueness_of_login_field_options.merge(options)
168
- end
25
+ alias login_field= login_field
169
26
 
170
27
  # This method allows you to find a record with the given login. If you
171
28
  # notice, with Active Record you have the UniquenessValidator class.
@@ -189,19 +46,9 @@ module Authlogic
189
46
  #
190
47
  # @api public
191
48
  def find_by_smart_case_login_field(login)
192
- if login_field
193
- find_with_case(
194
- login_field,
195
- login,
196
- validates_uniqueness_of_login_field_options[:case_sensitive] != false
197
- )
198
- else
199
- find_with_case(
200
- email_field,
201
- login,
202
- validates_uniqueness_of_email_field_options[:case_sensitive] != false
203
- )
204
- end
49
+ field = login_field || email_field
50
+ sensitive = Queries::CaseSensitivity.new(self, field).sensitive?
51
+ find_with_case(field, login, sensitive)
205
52
  end
206
53
 
207
54
  private
@@ -211,20 +58,6 @@ module Authlogic
211
58
  Queries::FindWithCase.new(self, field, value, sensitive).execute
212
59
  end
213
60
  end
214
-
215
- # All methods relating to the login field
216
- module Methods
217
- # Adds in various validations, modules, etc.
218
- def self.included(klass)
219
- klass.class_eval do
220
- if validate_login_field && login_field
221
- validates_length_of login_field, validates_length_of_login_field_options
222
- validates_format_of login_field, validates_format_of_login_field_options
223
- validates_uniqueness_of login_field, validates_uniqueness_of_login_field_options
224
- end
225
- end
226
- end
227
- end
228
61
  end
229
62
  end
230
63
  end
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Authlogic
2
4
  module ActsAsAuthentic
3
- # Magic columns are like ActiveRecord's created_at and updated_at columns. They are
4
- # "magically" maintained for you. Authlogic has the same thing, but these are
5
- # maintained on the session side. Please see Authlogic::Session::MagicColumns for more
6
- # details. This module merely adds validations for the magic columns if they exist.
5
+ # Magic columns are like ActiveRecord's created_at and updated_at columns.
6
+ # They are "magically" maintained for you. Authlogic has the same thing, but
7
+ # these are maintained on the session side. Please see "Magic Columns" in
8
+ # `Session::Base` for more details. This module merely adds validations for
9
+ # the magic columns if they exist.
7
10
  module MagicColumns
8
11
  def self.included(klass)
9
12
  klass.class_eval do