authlogic 4.4.1 → 4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f061d5824d3ae9539ebd01c0086805f45f7f7bf2
4
- data.tar.gz: 34898459a083fe21e33f015d2828503d814596d6
3
+ metadata.gz: 4b4e547d67102fc738dbad4fcbdfc00c68dd3efd
4
+ data.tar.gz: cd63b81ab7a2d498ac4a360d62b9db5ae672f634
5
5
  SHA512:
6
- metadata.gz: 18e5204b2c793b3dbe55302237451eb3a9dd5ac4746e133c99aba03884e7560333a8cd06f2d3ae2906a7eb4aff6569535db6353bee207191469889b4668757ce
7
- data.tar.gz: 0b622c6a789977e062c7fd862f35d2762d46c536261766c1706572c952bd751bc10eb7d24de8d2ab881e153982d4518a75f59ccbf52715c220a49602c9b0bd68
6
+ metadata.gz: f038e670ad640d9e2e601f35977629a6bc82f4d658fc1939e3633077fb0b5ce7ceafb49bbed462620dd34b153e8aa364127bb68e9712ddfdad7f28227cc2dd29
7
+ data.tar.gz: 7b97ce1b31c9abe5bdae7cfaa364f14f905f790a52d6160a18a7312c748cb81775d176d49bfeddab27ac2e89e04be032a8f55bd084725185c2e6f30386252bc0
data/.gitignore CHANGED
@@ -5,7 +5,6 @@
5
5
  *.sqlite3
6
6
  pkg/*
7
7
  coverage/*
8
- doc/*
9
8
  benchmarks/*
10
9
  .rvmrc
11
10
  gemfiles/Gemfile*.lock
@@ -16,6 +16,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
16
16
  * Fixed
17
17
  * None
18
18
 
19
+ ## 4.4.2 (2018-09-23)
20
+
21
+ * Breaking Changes
22
+ * None
23
+ * Added
24
+ * None
25
+ * Fixed
26
+ * Improved instructions in deprecation warning for validations
27
+
19
28
  ## 4.4.1 (2018-09-21)
20
29
 
21
30
  * Breaking Changes
data/README.md CHANGED
@@ -15,7 +15,7 @@ A clean, simple, and unobtrusive ruby authentication solution.
15
15
  | Version | Documentation |
16
16
  | ----------- | ------------- |
17
17
  | Unreleased | https://github.com/binarylogic/authlogic/blob/master/README.md |
18
- | 4.4.1 | https://github.com/binarylogic/authlogic/blob/v4.4.1/README.md |
18
+ | 4.4.2 | https://github.com/binarylogic/authlogic/blob/v4.4.2/README.md |
19
19
  | 3.7.0 | https://github.com/binarylogic/authlogic/blob/v3.7.0/README.md |
20
20
  | 2.1.11 | https://github.com/binarylogic/authlogic/blob/v2.1.11/README.rdoc |
21
21
  | 1.4.3 | https://github.com/binarylogic/authlogic/blob/v1.4.3/README.rdoc |
@@ -101,7 +101,7 @@ session = UserSession.find
101
101
  To get all of the nice authentication functionality in your model just do this:
102
102
 
103
103
  ```ruby
104
- class User < ActiveRecord::Base
104
+ class User < ApplicationRecord
105
105
  acts_as_authentic do |c|
106
106
  c.my_config_option = my_value
107
107
  end # the configuration block is optional
@@ -137,7 +137,7 @@ User.create(params[:user])
137
137
  You can switch this on and off with the following configuration:
138
138
 
139
139
  ```ruby
140
- class User < ActiveRecord::Base
140
+ class User < ApplicationRecord
141
141
  acts_as_authentic do |c|
142
142
  c.log_in_after_create = false
143
143
  end # the configuration block is optional
@@ -147,7 +147,7 @@ end
147
147
  Authlogic also updates the session when the user changes his/her password. You can also switch this on and off with the following configuration:
148
148
 
149
149
  ```ruby
150
- class User < ActiveRecord::Base
150
+ class User < ApplicationRecord
151
151
  acts_as_authentic do |c|
152
152
  c.log_in_after_password_change = false
153
153
  end # the configuration block is optional
@@ -228,6 +228,53 @@ class CreateUser < ActiveRecord::Migration
228
228
  end
229
229
  ```
230
230
 
231
+ In the `User` model,
232
+
233
+ ```ruby
234
+ class User < ApplicationRecord
235
+ acts_as_authentic
236
+
237
+ # Validate email, login, and password as you see fit.
238
+ #
239
+ # Authlogic < 5 added these validation for you, making them a little awkward
240
+ # to change. In 4.4.0, those automatic validations were deprecated. See
241
+ # https://github.com/binarylogic/authlogic/blob/master/doc/use_normal_rails_validation.md
242
+ validates :email,
243
+ format: {
244
+ with: ::Authlogic::Regex::EMAIL,
245
+ message: "should look like an email address."
246
+ },
247
+ length: { maximum: 100 },
248
+ uniqueness: {
249
+ case_sensitive: false,
250
+ if: :email_changed?
251
+ }
252
+
253
+ validates :login,
254
+ format: {
255
+ with: ::Authlogic::Regex::LOGIN,
256
+ message: "should use only letters, numbers, spaces, and .-_@+ please."
257
+ },
258
+ length: { within: 3..100 },
259
+ uniqueness: {
260
+ case_sensitive: false,
261
+ if: :login_changed?
262
+ }
263
+
264
+ validates :password,
265
+ confirmation: { if: :require_password? },
266
+ length: {
267
+ minimum: 8,
268
+ if: :require_password?
269
+ }
270
+ validates :password_confirmation,
271
+ length: {
272
+ minimum: 8,
273
+ if: :require_password?
274
+ }
275
+ end
276
+ ```
277
+
231
278
  ### 2.b. Controller
232
279
 
233
280
  Your sessions controller will look just like your other controllers.
@@ -0,0 +1,82 @@
1
+ # Use Normal ActiveRecord Validation
2
+
3
+ In Authlogic 4.4.0, [we deprecated][1] the features of Authlogic related to
4
+ validating email, login, and password. In 5.0.0 these features will be dropped.
5
+ Use normal ActiveRecord validations instead.
6
+
7
+ ## Instructions
8
+
9
+ First, disable the deprecated Authlogic validations:
10
+
11
+ acts_as_authentic do |c|
12
+ c.validate_email_field = false
13
+ c.validate_login_field = false
14
+ c.validate_password_field = false
15
+ end
16
+
17
+ Then, use normal ActiveRecord validations instead. For example, instead of
18
+ the Authlogic method validates_length_of_email_field_options, use
19
+
20
+ validates :email, length: { ... }
21
+
22
+ It might be a good idea to replace these one field at a time, ie. email,
23
+ then login, then password; one field per commit.
24
+
25
+ ## Default Values
26
+
27
+ The following validations represent the Authlogic < 5 defaults. Merge these
28
+ defaults with any settings you may have overwritten.
29
+
30
+ ```
31
+ validates :email,
32
+ format: {
33
+ with: ::Authlogic::Regex::EMAIL,
34
+ message: proc {
35
+ ::Authlogic::I18n.t(
36
+ "error_messages.email_invalid",
37
+ default: "should look like an email address."
38
+ )
39
+ }
40
+ },
41
+ length: { maximum: 100 },
42
+ uniqueness: {
43
+ case_sensitive: false,
44
+ if: :email_changed?
45
+ }
46
+
47
+ validates :login,
48
+ format: {
49
+ with: ::Authlogic::Regex::LOGIN,
50
+ message: proc {
51
+ ::Authlogic::I18n.t(
52
+ "error_messages.login_invalid",
53
+ default: "should use only letters, numbers, spaces, and .-_@+ please."
54
+ )
55
+ }
56
+ },
57
+ length: { within: 3..100 },
58
+ uniqueness: {
59
+ case_sensitive: false,
60
+ if: :login_changed?
61
+ }
62
+
63
+ validates :password,
64
+ confirmation: { if: :require_password? },
65
+ length: {
66
+ minimum: 8,
67
+ if: :require_password?
68
+ }
69
+ validates :password_confirmation,
70
+ length: {
71
+ minimum: 8,
72
+ if: :require_password?
73
+ }
74
+ ```
75
+
76
+ ## Motivation
77
+
78
+ The deprecated features save people some time in the begginning, when setting up
79
+ Authlogic. But, later in the life of a project, when these settings need to
80
+ change, it is obscure compared to normal ActiveRecord validations.
81
+
82
+ [1]: https://github.com/binarylogic/authlogic/pull/623
@@ -17,7 +17,7 @@ module Authlogic
17
17
  # This includes a lot of helpful methods for authenticating records
18
18
  # which the Authlogic::Session module relies on. To use it just do:
19
19
  #
20
- # class User < ActiveRecord::Base
20
+ # class User < ApplicationRecord
21
21
  # acts_as_authentic
22
22
  # end
23
23
  #
@@ -13,7 +13,7 @@ module Authlogic
13
13
  # that specific account. To implement this via ActiveRecord do something
14
14
  # like:
15
15
  #
16
- # class User < ActiveRecord::Base
16
+ # class User < ApplicationRecord
17
17
  # authenticates_many :user_sessions
18
18
  # end
19
19
  class Association
@@ -3,7 +3,7 @@ module Authlogic
3
3
  # to an account, you want to make sure only users that belong to that account can
4
4
  # actually login into that account. Simple, just do:
5
5
  #
6
- # class Account < ActiveRecord::Base
6
+ # class Account < ApplicationRecord
7
7
  # authenticates_many :user_sessions
8
8
  # end
9
9
  #
@@ -2,12 +2,8 @@ module Authlogic
2
2
  module Config
3
3
  E_USE_NORMAL_RAILS_VALIDATION = <<~EOS.freeze
4
4
  This Authlogic configuration option (%s) is deprecated. Use normal
5
- ActiveRecord validations instead. For example, instead of the Authlogic
6
- method validates_length_of_email_field_options, you can use
7
-
8
- validates :email, length: { ... }
9
-
10
- These deprecated Authlogic methods will be removed in the next major version.
5
+ ActiveRecord validation instead. Detailed instructions:
6
+ https://github.com/binarylogic/authlogic/blob/master/doc/use_normal_rails_validation.md
11
7
  EOS
12
8
 
13
9
  def self.extended(klass)
@@ -32,7 +32,7 @@ module Authlogic
32
32
  # # Authlogic options go here
33
33
  # end
34
34
  #
35
- # class User < ActiveRecord::Base
35
+ # class User < ApplicationRecord
36
36
  # acts_as_authentic
37
37
  # end
38
38
  #
@@ -16,6 +16,6 @@ module Authlogic
16
16
  #
17
17
  # @api public
18
18
  def self.gem_version
19
- ::Gem::Version.new("4.4.1")
19
+ ::Gem::Version.new("4.4.2")
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  binary_logic:
2
2
  name: Binary Logic
3
-
3
+
4
4
  logic_over_data:
5
- name: Logic Over Data
5
+ name: Logic Over Data
@@ -6,7 +6,7 @@ drew:
6
6
  persistence_token: 5273d85ed156e9dbd6a7c1438d319ef8c8d41dd24368db6c222de11346c7b11e53ee08d45ecf619b1c1dc91233d22b372482b751b066d0a6f6f9bac42eacaabf
7
7
  first_name: Drew
8
8
  last_name: Gainor
9
-
9
+
10
10
  jennifer:
11
11
  company: logic_over_data
12
12
  email: jjohnson@logicoverdata.com
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1
4
+ version: 4.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-09-21 00:00:00.000000000 Z
13
+ date: 2018-09-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -180,6 +180,7 @@ files:
180
180
  - Rakefile
181
181
  - UPGRADING.md
182
182
  - authlogic.gemspec
183
+ - doc/use_normal_rails_validation.md
183
184
  - gemfiles/Gemfile.rails-4.2.x
184
185
  - gemfiles/Gemfile.rails-5.1.x
185
186
  - gemfiles/Gemfile.rails-5.2.x