current_session 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -16
- data/current_session.gemspec +1 -2
- data/lib/current_session/auth.rb +4 -3
- data/lib/current_session/base.rb +22 -7
- data/lib/current_session/interface.rb +1 -1
- data/lib/current_session/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc53442f7b800e43a4da8cc2690d72ba5466be6afce2b6d28fed7e3e62de9fea
|
4
|
+
data.tar.gz: 46364f6ee395e2e2734cb0784cf700793dafb022963960d7478a5397feac8bd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95c0d5af5fd5a896d277ccbb5955675ddaa04ee2caf52b41918c1aa1eae6cf0ca15d3c0cf781eddba225b3eef613a377054309347ddb3f1ae3e45b1f2002562f
|
7
|
+
data.tar.gz: f8e4b72b8bab60b40af08cf0a7fedcb8cc9613e7aab7a73a8d5d97b4fb7732ccccbd59c8a76890daed5b6382efe9f6e6c9a894fc99db18a9c7a316b99d9ed7b3
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
current_session (0.1.
|
5
|
-
activesupport
|
4
|
+
current_session (0.1.4)
|
5
|
+
activesupport (>= 6.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (7.0.
|
11
|
-
activesupport (= 7.0.
|
12
|
-
activerecord (7.0.
|
13
|
-
activemodel (= 7.0.
|
14
|
-
activesupport (= 7.0.
|
15
|
-
activesupport (7.0.
|
10
|
+
activemodel (7.0.4)
|
11
|
+
activesupport (= 7.0.4)
|
12
|
+
activerecord (7.0.4)
|
13
|
+
activemodel (= 7.0.4)
|
14
|
+
activesupport (= 7.0.4)
|
15
|
+
activesupport (7.0.4)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
@@ -39,12 +39,12 @@ GEM
|
|
39
39
|
pry (0.14.1)
|
40
40
|
coderay (~> 1.1)
|
41
41
|
method_source (~> 1.0)
|
42
|
-
rack (
|
43
|
-
rack-protection (
|
42
|
+
rack (3.0.0)
|
43
|
+
rack-protection (3.0.1)
|
44
44
|
rack
|
45
45
|
rainbow (3.1.1)
|
46
46
|
rake (13.0.6)
|
47
|
-
regexp_parser (2.
|
47
|
+
regexp_parser (2.6.0)
|
48
48
|
rexml (3.2.5)
|
49
49
|
rspec (3.11.0)
|
50
50
|
rspec-core (~> 3.11.0)
|
@@ -52,14 +52,14 @@ GEM
|
|
52
52
|
rspec-mocks (~> 3.11.0)
|
53
53
|
rspec-core (3.11.0)
|
54
54
|
rspec-support (~> 3.11.0)
|
55
|
-
rspec-expectations (3.11.
|
55
|
+
rspec-expectations (3.11.1)
|
56
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
57
57
|
rspec-support (~> 3.11.0)
|
58
58
|
rspec-mocks (3.11.1)
|
59
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
60
60
|
rspec-support (~> 3.11.0)
|
61
|
-
rspec-support (3.11.
|
62
|
-
rubocop (1.
|
61
|
+
rspec-support (3.11.1)
|
62
|
+
rubocop (1.36.0)
|
63
63
|
json (~> 2.3)
|
64
64
|
parallel (~> 1.10)
|
65
65
|
parser (>= 3.1.2.1)
|
@@ -78,10 +78,10 @@ GEM
|
|
78
78
|
simplecov_json_formatter (~> 0.1)
|
79
79
|
simplecov-html (0.12.3)
|
80
80
|
simplecov_json_formatter (0.1.4)
|
81
|
-
sqlite3 (1.
|
81
|
+
sqlite3 (1.5.1-arm64-darwin)
|
82
82
|
tzinfo (2.0.5)
|
83
83
|
concurrent-ruby (~> 1.0)
|
84
|
-
unicode-display_width (2.
|
84
|
+
unicode-display_width (2.3.0)
|
85
85
|
|
86
86
|
PLATFORMS
|
87
87
|
arm64-darwin-20
|
data/current_session.gemspec
CHANGED
@@ -27,8 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
|
31
|
-
spec.add_runtime_dependency "activesupport"
|
30
|
+
spec.add_runtime_dependency "activesupport", ">= 6.0.0"
|
32
31
|
|
33
32
|
# For more information and examples about making a new gem, checkout our
|
34
33
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/current_session/auth.rb
CHANGED
@@ -5,11 +5,12 @@ module CurrentSession
|
|
5
5
|
# Base class for providing auth methods
|
6
6
|
#
|
7
7
|
class Auth
|
8
|
-
|
8
|
+
class_attribute :user_class
|
9
|
+
|
10
|
+
def initialize(request)
|
9
11
|
@request = request
|
10
|
-
@user_class = user_class
|
11
12
|
end
|
12
|
-
attr_reader :request
|
13
|
+
attr_reader :request
|
13
14
|
|
14
15
|
def auth
|
15
16
|
request.env["omniauth.auth"]
|
data/lib/current_session/base.rb
CHANGED
@@ -10,7 +10,13 @@ module CurrentSession
|
|
10
10
|
attribute :current_user
|
11
11
|
|
12
12
|
class << self
|
13
|
-
attr_accessor :
|
13
|
+
attr_accessor :session_token_class
|
14
|
+
attr_reader :user_class
|
15
|
+
|
16
|
+
def user_class=(user_class)
|
17
|
+
@user_class = user_class
|
18
|
+
@auth_class.user_class = user_class if @auth_class
|
19
|
+
end
|
14
20
|
|
15
21
|
def current_time(_)
|
16
22
|
Time.current
|
@@ -21,9 +27,13 @@ module CurrentSession
|
|
21
27
|
end
|
22
28
|
|
23
29
|
def session_methods(&block)
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
if block
|
31
|
+
session_methods = Module.new(&block)
|
32
|
+
@session_repository_class = Class.new(CurrentSession::Repository) { include session_methods }
|
33
|
+
@session_methods = session_methods
|
34
|
+
else
|
35
|
+
@session_methods
|
36
|
+
end
|
27
37
|
end
|
28
38
|
|
29
39
|
def auth_methods=(auth_methods_module)
|
@@ -31,9 +41,14 @@ module CurrentSession
|
|
31
41
|
end
|
32
42
|
|
33
43
|
def auth_methods(&block)
|
34
|
-
|
35
|
-
|
36
|
-
|
44
|
+
if block
|
45
|
+
auth_methods = Module.new(&block)
|
46
|
+
@auth_class = Class.new(CurrentSession::Auth) { include auth_methods }
|
47
|
+
@auth_class.user_class = user_class
|
48
|
+
@auth_methods = auth_methods
|
49
|
+
else
|
50
|
+
@auth_methods
|
51
|
+
end
|
37
52
|
end
|
38
53
|
end
|
39
54
|
end
|
@@ -19,7 +19,7 @@ module CurrentSession
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def create(request)
|
22
|
-
auth = @auth_class.new(request
|
22
|
+
auth = @auth_class.new(request)
|
23
23
|
auth.find_or_create_by_auth.try do |user|
|
24
24
|
auth.update(user)
|
25
25
|
session_repository(request).update_session_token(user)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: current_session
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masa (Aileron inc)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|