authie 4.0.0.rc4 → 4.0.0.rc5

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
  SHA256:
3
- metadata.gz: 99cb3ea1143001fdb259df6d251223036ae94ac4f2661d9732e01b9438a67702
4
- data.tar.gz: 261dd3764202502100c0ba19bc649cb7cf3c09b57250d1643b0f14c35e10f2f3
3
+ metadata.gz: 1d9373c828cdac9b7663eb05db6954ff069f5e6d8164d64c8dcf5fd165ca0d09
4
+ data.tar.gz: c4b98e9bb20edce2539761806affda87fd4d56082b7c9e956842424cac8a6e27
5
5
  SHA512:
6
- metadata.gz: b1bfae12c744d812a64dc757b6524f3b09f951adf5f62528e96560dcb93f0424d4590575b5a082a715402c1dbfe8f8721b184fb4b369a9f71b1b51a9c318c81b
7
- data.tar.gz: 8c344e7933ec8d13bea40130ba0974a9f2ac97fd5bcb3aa0694305b140b290f4a6a1082cfcfbba82261a11f0bf6c2611662acdb7fc65506b5107b09250f61fae
6
+ metadata.gz: b90a45ff82b29992deec7c2e7c09604a3a569bdfbe099ba2f7be26989c9bd91417b7446d7ea2d8ad0f85f55d42d9ed9356a203dc239e88f568ccf64cb4faa363
7
+ data.tar.gz: 9c66674049a1a8c36389faa84764b296f7879d59b5cdd3c6bc7b06946874ffec6fec23cd1194a0b68367391237814938a1de19db0ef7958af005d7a9ce2d66ef
@@ -36,18 +36,25 @@ module Authie
36
36
  proposed_browser_id
37
37
  end
38
38
 
39
- # Touch the session on each request to ensure that it is validated and all last activity
40
- # information is updated. This will return the session if one has been touched otherwise
41
- # it will reteurn false if there is no session/not logged in. It is safe to run this on
42
- # all requests even if there is no session.
39
+ # Validate the auth session to ensure that it is current validate and raise an error if it
40
+ # is not suitable for use.
43
41
  #
44
42
  # @return [Authie::Session, false]
45
- def touch_auth_session
46
- return auth_session.touch if logged_in?
43
+ def validate_auth_session
44
+ return auth_session.validate if logged_in?
47
45
 
48
46
  false
49
47
  end
50
48
 
49
+ # Touch the session to update details on the latest activity.
50
+ #
51
+ # @return [Authie::Session, false]
52
+ def touch_auth_session
53
+ yield if block_given?
54
+ ensure
55
+ auth_session.touch if logged_in?
56
+ end
57
+
51
58
  # Return the user for the currently logged in user or nil if no user is logged in
52
59
  #
53
60
  # @return [ActiveRecord::Base, nil]
@@ -7,9 +7,11 @@ module Authie
7
7
  class << self
8
8
  def included(base)
9
9
  base.helper_method :logged_in?, :current_user, :auth_session
10
- base.before_action :set_browser_id, :touch_auth_session
10
+ base.before_action :set_browser_id, :validate_auth_session
11
+ base.around_action :touch_auth_session
11
12
 
12
13
  base.delegate :set_browser_id, to: :auth_session_delegate
14
+ base.delegate :validate_auth_session, to: :auth_session_delegate
13
15
  base.delegate :touch_auth_session, to: :auth_session_delegate
14
16
  base.delegate :current_user, to: :auth_session_delegate
15
17
  base.delegate :create_auth_session, to: :auth_session_delegate
@@ -88,7 +88,6 @@ module Authie
88
88
  # @raises [ActiveRecord::RecordInvalid]
89
89
  # @return [Authie::Session]
90
90
  def touch
91
- validate
92
91
  @session.last_activity_at = Time.now
93
92
  @session.last_activity_ip = @controller.request.ip
94
93
  @session.last_activity_path = @controller.request.path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authie
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc4
4
+ version: 4.0.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-29 00:00:00.000000000 Z
11
+ date: 2022-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord