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
@@ -1,138 +0,0 @@
1
- require "request_store"
2
-
3
- module Authlogic
4
- module Session
5
- # Authentication can be scoped, and it's easy, you just need to define how you want to
6
- # scope everything. This should help you:
7
- #
8
- # 1. Want to scope by a parent object? Ex: An account has many users.
9
- # Checkout Authlogic::AuthenticatesMany
10
- # 2. Want to scope the validations in your model? Ex: 2 users can have the same login
11
- # under different accounts. See Authlogic::ActsAsAuthentic::Scope
12
- module Scopes # :nodoc:
13
- def self.included(klass)
14
- klass.class_eval do
15
- extend ClassMethods
16
- include InstanceMethods
17
- attr_writer :scope
18
- end
19
- end
20
-
21
- # = Scopes
22
- module ClassMethods
23
- # The current scope set, should be used in the block passed to with_scope.
24
- def scope
25
- RequestStore.store[:authlogic_scope]
26
- end
27
-
28
- # What with_scopes focuses on is scoping the query when finding the
29
- # object and the name of the cookie / session. It works very similar to
30
- # ActiveRecord::Base#with_scopes. It accepts a hash with any of the
31
- # following options:
32
- #
33
- # * <tt>find_options:</tt> any options you can pass into ActiveRecord::Base.find.
34
- # This is used when trying to find the record.
35
- # * <tt>id:</tt> The id of the session, this gets merged with the real id. For
36
- # information ids see the id method.
37
- #
38
- # Here is how you use it:
39
- #
40
- # ```
41
- # UserSession.with_scope(find_options: {conditions: "account_id = 2"}, id: "account_2") do
42
- # UserSession.find
43
- # end
44
- # ```
45
- #
46
- # Essentially what the above does is scope the searching of the object
47
- # with the sql you provided. So instead of:
48
- #
49
- # ```
50
- # User.where("login = 'ben'").first
51
- # ```
52
- #
53
- # it would be:
54
- #
55
- # ```
56
- # User.where("login = 'ben' and account_id = 2").first
57
- # ```
58
- #
59
- # You will also notice the :id option. This works just like the id
60
- # method. It scopes your cookies. So the name of your cookie will be:
61
- #
62
- # account_2_user_credentials
63
- #
64
- # instead of:
65
- #
66
- # user_credentials
67
- #
68
- # What is also nifty about scoping with an :id is that it merges your
69
- # id's. So if you do:
70
- #
71
- # UserSession.with_scope(
72
- # find_options: { conditions: "account_id = 2"},
73
- # id: "account_2"
74
- # ) do
75
- # session = UserSession.new
76
- # session.id = :secure
77
- # end
78
- #
79
- # The name of your cookies will be:
80
- #
81
- # secure_account_2_user_credentials
82
- def with_scope(options = {})
83
- raise ArgumentError.new("You must provide a block") unless block_given?
84
- self.scope = options
85
- result = yield
86
- self.scope = nil
87
- result
88
- end
89
-
90
- private
91
-
92
- def scope=(value)
93
- RequestStore.store[:authlogic_scope] = value
94
- end
95
- end
96
-
97
- module InstanceMethods
98
- # Setting the scope if it exists upon instantiation.
99
- def initialize(*args)
100
- self.scope = self.class.scope
101
- super
102
- end
103
-
104
- # The scope of the current object
105
- def scope
106
- @scope ||= {}
107
- end
108
-
109
- private
110
-
111
- # Used for things like cookie_key, session_key, etc.
112
- def build_key(last_part)
113
- [scope[:id], super].compact.join("_")
114
- end
115
-
116
- # `args[0]` is the name of an AR method, like
117
- # `find_by_single_access_token`.
118
- def search_for_record(*args)
119
- search_scope.scoping do
120
- klass.send(*args)
121
- end
122
- end
123
-
124
- # Returns an AR relation representing the scope of the search. The
125
- # relation is either provided directly by, or defined by
126
- # `find_options`.
127
- def search_scope
128
- if scope[:find_options].is_a?(ActiveRecord::Relation)
129
- scope[:find_options]
130
- else
131
- conditions = scope[:find_options] && scope[:find_options][:conditions] || {}
132
- klass.send(:where, conditions)
133
- end
134
- end
135
- end
136
- end
137
- end
138
- end
@@ -1,77 +0,0 @@
1
- module Authlogic
2
- module Session
3
- # Handles all parts of authentication that deal with sessions. Such as persisting a
4
- # session and saving / destroy a session.
5
- module Session
6
- def self.included(klass)
7
- klass.class_eval do
8
- extend Config
9
- include InstanceMethods
10
- persist :persist_by_session
11
- after_save :update_session
12
- after_destroy :update_session
13
- after_persisting :update_session, unless: :single_access?
14
- end
15
- end
16
-
17
- # Configuration for the session feature.
18
- module Config
19
- # Works exactly like cookie_key, but for sessions. See cookie_key for more info.
20
- #
21
- # * <tt>Default:</tt> cookie_key
22
- # * <tt>Accepts:</tt> Symbol or String
23
- def session_key(value = nil)
24
- rw_config(:session_key, value, cookie_key)
25
- end
26
- alias_method :session_key=, :session_key
27
- end
28
-
29
- # Instance methods for the session feature.
30
- module InstanceMethods
31
- private
32
-
33
- # Tries to validate the session from information in the session
34
- def persist_by_session
35
- persistence_token, record_id = session_credentials
36
- if !persistence_token.nil?
37
- record = persist_by_session_search(persistence_token, record_id)
38
- if record && record.persistence_token == persistence_token
39
- self.unauthorized_record = record
40
- end
41
- valid?
42
- else
43
- false
44
- end
45
- end
46
-
47
- # Allow finding by persistence token, because when records are created
48
- # the session is maintained in a before_save, when there is no id.
49
- # This is done for performance reasons and to save on queries.
50
- def persist_by_session_search(persistence_token, record_id)
51
- if record_id.nil?
52
- search_for_record("find_by_persistence_token", persistence_token.to_s)
53
- else
54
- search_for_record("find_by_#{klass.primary_key}", record_id.to_s)
55
- end
56
- end
57
-
58
- def session_credentials
59
- [
60
- controller.session[session_key],
61
- controller.session["#{session_key}_#{klass.primary_key}"]
62
- ].collect { |i| i.nil? ? i : i.to_s }.compact
63
- end
64
-
65
- def session_key
66
- build_key(self.class.session_key)
67
- end
68
-
69
- def update_session
70
- controller.session[session_key] = record && record.persistence_token
71
- compound_key = "#{session_key}_#{klass.primary_key}"
72
- controller.session[compound_key] = record && record.send(record.class.primary_key)
73
- end
74
- end
75
- end
76
- end
77
- end
@@ -1,103 +0,0 @@
1
- module Authlogic
2
- module Session
3
- # Think about financial websites, if you are inactive for a certain period
4
- # of time you will be asked to log back in on your next request. You can do
5
- # this with Authlogic easily, there are 2 parts to this:
6
- #
7
- # 1. Define the timeout threshold:
8
- #
9
- # acts_as_authentic do |c|
10
- # c.logged_in_timeout = 10.minutes # default is 10.minutes
11
- # end
12
- #
13
- # 2. Enable logging out on timeouts
14
- #
15
- # class UserSession < Authlogic::Session::Base
16
- # logout_on_timeout true # default if false
17
- # end
18
- #
19
- # This will require a user to log back in if they are inactive for more than
20
- # 10 minutes. In order for this feature to be used you must have a
21
- # last_request_at datetime column in your table for whatever model you are
22
- # authenticating with.
23
- module Timeout
24
- def self.included(klass)
25
- klass.class_eval do
26
- extend Config
27
- include InstanceMethods
28
- before_persisting :reset_stale_state
29
- after_persisting :enforce_timeout
30
- attr_accessor :stale_record
31
- end
32
- end
33
-
34
- # Configuration for the timeout feature.
35
- module Config
36
- # With acts_as_authentic you get a :logged_in_timeout configuration
37
- # option. If this is set, after this amount of time has passed the user
38
- # will be marked as logged out. Obviously, since web based apps are on a
39
- # per request basis, we have to define a time limit threshold that
40
- # determines when we consider a user to be "logged out". Meaning, if
41
- # they login and then leave the website, when do mark them as logged
42
- # out? I recommend just using this as a fun feature on your website or
43
- # reports, giving you a ballpark number of users logged in and active.
44
- # This is not meant to be a dead accurate representation of a user's
45
- # logged in state, since there is really no real way to do this with web
46
- # based apps. Think about a user that logs in and doesn't log out. There
47
- # is no action that tells you that the user isn't technically still
48
- # logged in and active.
49
- #
50
- # That being said, you can use that feature to require a new login if
51
- # their session times out. Similar to how financial sites work. Just set
52
- # this option to true and if your record returns true for stale? then
53
- # they will be required to log back in.
54
- #
55
- # Lastly, UserSession.find will still return an object if the session is
56
- # stale, but you will not get a record. This allows you to determine if
57
- # the user needs to log back in because their session went stale, or
58
- # because they just aren't logged in. Just call
59
- # current_user_session.stale? as your flag.
60
- #
61
- # * <tt>Default:</tt> false
62
- # * <tt>Accepts:</tt> Boolean
63
- def logout_on_timeout(value = nil)
64
- rw_config(:logout_on_timeout, value, false)
65
- end
66
- alias_method :logout_on_timeout=, :logout_on_timeout
67
- end
68
-
69
- # Instance methods for the timeout feature.
70
- module InstanceMethods
71
- # Tells you if the record is stale or not. Meaning the record has timed
72
- # out. This will only return true if you set logout_on_timeout to true
73
- # in your configuration. Basically how a bank website works. If you
74
- # aren't active over a certain period of time your session becomes stale
75
- # and requires you to log back in.
76
- def stale?
77
- if remember_me?
78
- remember_me_expired?
79
- else
80
- !stale_record.nil? || (logout_on_timeout? && record && record.logged_out?)
81
- end
82
- end
83
-
84
- private
85
-
86
- def reset_stale_state
87
- self.stale_record = nil
88
- end
89
-
90
- def enforce_timeout
91
- if stale?
92
- self.stale_record = record
93
- self.record = nil
94
- end
95
- end
96
-
97
- def logout_on_timeout?
98
- self.class.logout_on_timeout == true
99
- end
100
- end
101
- end
102
- end
103
- end
@@ -1,56 +0,0 @@
1
- module Authlogic
2
- module Session
3
- # Allows you to create session with an object. Ex:
4
- #
5
- # UserSession.create(my_user_object)
6
- #
7
- # Be careful with this, because Authlogic is assuming that you have already
8
- # confirmed that the user is who he says he is.
9
- #
10
- # For example, this is the method used to persist the session internally.
11
- # Authlogic finds the user with the persistence token. At this point we know
12
- # the user is who he says he is, so Authlogic just creates a session with
13
- # the record. This is particularly useful for 3rd party authentication
14
- # methods, such as OpenID. Let that method verify the identity, once it's
15
- # verified, pass the object and create a session.
16
- module UnauthorizedRecord
17
- def self.included(klass)
18
- klass.class_eval do
19
- attr_accessor :unauthorized_record
20
- validate(
21
- :validate_by_unauthorized_record,
22
- if: :authenticating_with_unauthorized_record?
23
- )
24
- end
25
- end
26
-
27
- # Returning meaningful credentials
28
- def credentials
29
- if authenticating_with_unauthorized_record?
30
- details = {}
31
- details[:unauthorized_record] = "<protected>"
32
- details
33
- else
34
- super
35
- end
36
- end
37
-
38
- # Setting the unauthorized record if it exists in the credentials passed.
39
- def credentials=(value)
40
- super
41
- values = value.is_a?(Array) ? value : [value]
42
- self.unauthorized_record = values.first if values.first.class < ::ActiveRecord::Base
43
- end
44
-
45
- private
46
-
47
- def authenticating_with_unauthorized_record?
48
- !unauthorized_record.nil?
49
- end
50
-
51
- def validate_by_unauthorized_record
52
- self.attempted_record = unauthorized_record
53
- end
54
- end
55
- end
56
- end
@@ -1,93 +0,0 @@
1
- module Authlogic
2
- module Session
3
- # Responsible for session validation
4
- module Validation
5
- # The errors in Authlogic work JUST LIKE ActiveRecord. In fact, it uses
6
- # the exact same ActiveRecord errors class. Use it the same way:
7
- #
8
- # class UserSession
9
- # validate :check_if_awesome
10
- #
11
- # private
12
- # def check_if_awesome
13
- # errors.add(:login, "must contain awesome") if login && !login.include?("awesome")
14
- # errors.add(:base, "You must be awesome to log in") unless attempted_record.awesome?
15
- # end
16
- # end
17
- class Errors < (defined?(::ActiveModel) ? ::ActiveModel::Errors : ::ActiveRecord::Errors)
18
- unless defined?(::ActiveModel)
19
- def [](key)
20
- value = super
21
- value.is_a?(Array) ? value : [value].compact
22
- end
23
- end
24
- end
25
-
26
- # You should use this as a place holder for any records that you find
27
- # during validation. The main reason for this is to allow other modules to
28
- # use it if needed. Take the failed_login_count feature, it needs this in
29
- # order to increase the failed login count.
30
- def attempted_record
31
- @attempted_record
32
- end
33
-
34
- # See attempted_record
35
- def attempted_record=(value)
36
- @attempted_record = value
37
- end
38
-
39
- # The errors in Authlogic work JUST LIKE ActiveRecord. In fact, it uses
40
- # the exact same ActiveRecord errors class. Use it the same way:
41
- #
42
- # === Example
43
- #
44
- # class UserSession
45
- # before_validation :check_if_awesome
46
- #
47
- # private
48
- # def check_if_awesome
49
- # errors.add(:login, "must contain awesome") if login && !login.include?("awesome")
50
- # errors.add(:base, "You must be awesome to log in") unless attempted_record.awesome?
51
- # end
52
- # end
53
- def errors
54
- @errors ||= Errors.new(self)
55
- end
56
-
57
- # Determines if the information you provided for authentication is valid
58
- # or not. If there is a problem with the information provided errors will
59
- # be added to the errors object and this method will return false.
60
- def valid?
61
- errors.clear
62
- self.attempted_record = nil
63
-
64
- before_validation
65
- new_session? ? before_validation_on_create : before_validation_on_update
66
- validate
67
- ensure_authentication_attempted
68
-
69
- if errors.empty?
70
- new_session? ? after_validation_on_create : after_validation_on_update
71
- after_validation
72
- end
73
-
74
- save_record(attempted_record)
75
- errors.empty?
76
- end
77
-
78
- private
79
-
80
- def ensure_authentication_attempted
81
- if errors.empty? && attempted_record.nil?
82
- errors.add(
83
- :base,
84
- I18n.t(
85
- "error_messages.no_authentication_details",
86
- default: "You did not provide any details for authentication."
87
- )
88
- )
89
- end
90
- end
91
- end
92
- end
93
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- module ActsAsAuthenticTest
6
- class BaseTest < ActiveSupport::TestCase
7
- def test_acts_as_authentic
8
- assert_nothing_raised do
9
- User.acts_as_authentic do
10
- end
11
- end
12
- end
13
-
14
- def test_acts_as_authentic_with_old_config
15
- assert_raise(ArgumentError) do
16
- User.acts_as_authentic({})
17
- end
18
- end
19
-
20
- def test_acts_as_authentic_with_no_table
21
- klass = Class.new(ActiveRecord::Base)
22
- assert_nothing_raised do
23
- klass.acts_as_authentic
24
- end
25
- end
26
- end
27
- end