oauth_im 0.9.3 → 0.9.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3de11fe5ca4fd11cd2d762e7cde0501b1d2f05310991efe187d20b9f035834e1
|
4
|
+
data.tar.gz: c80dd50d7c7c7f0c1b32f0aab6f9fad43f4a42e0d841d7efd3523786b7710cb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9a6298a624e5c4cc51dfda4bd79920d8d729c8cbbdd9f8a7723e95f2e3aac5c69f36fa4d733e18b9b503e65ba9185a37d88362705d8663572f3e5fb60bf02ad
|
7
|
+
data.tar.gz: 05b8f611dc5f111eca6865d2115b26b44abc0ccab2b582b7f9ed9fbf3e3f70b8f5e0a1930fb557c70772f128394fd057ca90983f2b7f8c4acaac4ce8de9508d7
|
@@ -12,10 +12,12 @@ module OauthIm
|
|
12
12
|
private
|
13
13
|
|
14
14
|
delegate :email, :email_verified?,
|
15
|
-
:
|
15
|
+
:user_is_sponsor?,
|
16
16
|
to: :user_client,
|
17
17
|
allow_nil: true
|
18
18
|
|
19
|
+
delegate :spec_user, :spec_user_is_sponsor?, to: AppContext
|
20
|
+
|
19
21
|
def authenticated?
|
20
22
|
AppContext.authenticated_for_specs? ||
|
21
23
|
(AppContext.provide_authentication? && logged_in?)
|
@@ -32,10 +34,10 @@ module OauthIm
|
|
32
34
|
|
33
35
|
def current_user
|
34
36
|
@current_user ||=
|
35
|
-
if
|
37
|
+
if Rails.env.test?
|
38
|
+
spec_user
|
39
|
+
elsif user_jwt.present?
|
36
40
|
email if email_verified?
|
37
|
-
elsif Rails.env.test?
|
38
|
-
AppContext.spec_user
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -3,8 +3,11 @@
|
|
3
3
|
module AppContext
|
4
4
|
module_function
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
TEST_ENV_ERROR_MESSAGE = 'Use only in test environment!'
|
7
|
+
|
8
|
+
def override_for_specs?
|
9
|
+
Rails.env.test? && provide_authentication?
|
10
|
+
end
|
8
11
|
|
9
12
|
def provide_authentication?
|
10
13
|
true
|
@@ -18,46 +21,37 @@ module AppContext
|
|
18
21
|
@spec_user if override_for_specs?
|
19
22
|
end
|
20
23
|
|
21
|
-
def
|
22
|
-
@
|
23
|
-
end
|
24
|
-
|
25
|
-
def spec_user_data
|
26
|
-
if override_for_specs?
|
27
|
-
@spec_user_data.presence || DEFAULT_SPEC_USER_DATA
|
28
|
-
else
|
29
|
-
DEFAULT_SPEC_USER_DATA
|
30
|
-
end
|
24
|
+
def spec_user_is_sponsor?
|
25
|
+
@spec_user_is_sponsor && override_for_specs?
|
31
26
|
end
|
32
27
|
|
33
|
-
def
|
34
|
-
|
28
|
+
def authenticated_for_specs?
|
29
|
+
@authenticated_for_specs && override_for_specs?
|
35
30
|
end
|
36
31
|
|
37
32
|
def authenticate_for_specs?
|
38
|
-
raise
|
33
|
+
raise TEST_ENV_ERROR_MESSAGE unless Rails.env.test?
|
39
34
|
|
40
35
|
provide_authentication?
|
41
36
|
end
|
42
37
|
|
43
|
-
def authenticate_for_specs(spec_user: nil,
|
38
|
+
def authenticate_for_specs(spec_user: nil, sponsor: false)
|
44
39
|
return unless authenticate_for_specs?
|
45
40
|
|
46
|
-
|
41
|
+
initialize_spec_user spec_user: spec_user, sponsor: sponsor
|
47
42
|
yield
|
48
43
|
reset_spec_user
|
49
44
|
end
|
50
45
|
|
51
|
-
def
|
52
|
-
@authenticated_for_specs = true
|
46
|
+
def initialize_spec_user(spec_user:, sponsor:)
|
53
47
|
@spec_user = spec_user
|
54
|
-
@
|
48
|
+
@spec_user_is_sponsor = sponsor
|
49
|
+
@authenticated_for_specs = true
|
55
50
|
end
|
56
51
|
|
57
52
|
def reset_spec_user
|
58
|
-
@spec_user_data = DEFAULT_SPEC_USER_DATA
|
59
|
-
@spec_user = nil
|
60
53
|
@authenticated_for_specs = false
|
61
|
-
nil
|
54
|
+
@spec_user = nil
|
55
|
+
@spec_user_is_sponsor = false
|
62
56
|
end
|
63
57
|
end
|
data/lib/oauth_im/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth_im
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Connally
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fusionauth_client
|