tramway-api 2.0 → 2.0.0.1
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: c5ab385b1f17e7f65727c6601d470043e3c76c393409f38b914d79c05e6df524
|
4
|
+
data.tar.gz: d82903e94875d6a00eb3c885ccf0b28b11c62e1183abec7e5ff1d646b1b8224d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 226e85b0c6f7ce0f46ab03f0ae1be2bad0ef7ac645a45498473520b86d4e36ab05ef56d02c3fa3a0f2dc57e50d1a99ca4b6fe934072df8938ee55ebd33875688
|
7
|
+
data.tar.gz: e14d07574e5d6cc8603707ec5b95f46f2b9ddcff0f7be5d5ee127db0e72daefb02cbe9de1f1d0bf7410051b9aec6c249e6e0f7f3f8b92a390b3a02d9241992cc
|
@@ -16,7 +16,7 @@ module Tramway
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def authenticate
|
19
|
-
return if
|
19
|
+
return if current_tramway_user || params[:user_based_model].in?(Tramway::Api.user_based_models)
|
20
20
|
|
21
21
|
unauthorized
|
22
22
|
end
|
@@ -54,7 +54,7 @@ module Tramway
|
|
54
54
|
params[:auth]&.permit(:login, :password)
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
57
|
+
def current_tramway_user
|
58
58
|
Tramway::Api.user_based_models.map do |user_based_model|
|
59
59
|
send("current_#{user_based_model.constantize.name.underscore}") unless user_based_model == User
|
60
60
|
end.compact.first
|
@@ -44,7 +44,7 @@ module Tramway
|
|
44
44
|
|
45
45
|
def check_available_model_class
|
46
46
|
unless model_class
|
47
|
-
head(:unauthorized) && return unless
|
47
|
+
head(:unauthorized) && return unless current_tramway_user
|
48
48
|
|
49
49
|
head(:unprocessable_entity) && return
|
50
50
|
end
|
@@ -53,7 +53,7 @@ module Tramway
|
|
53
53
|
def check_available_model_action_for_record
|
54
54
|
action_is_available = check_action
|
55
55
|
action_is_available.tap do
|
56
|
-
if action_is_available.is_a?(Proc) && !action_is_available.call(record,
|
56
|
+
if action_is_available.is_a?(Proc) && !action_is_available.call(record, current_tramway_user)
|
57
57
|
head(:unprocessable_entity) && return
|
58
58
|
end
|
59
59
|
end
|
@@ -63,7 +63,7 @@ module Tramway
|
|
63
63
|
action_is_available = check_action
|
64
64
|
return records if action_is_available == true
|
65
65
|
|
66
|
-
action_is_available.call records,
|
66
|
+
action_is_available.call records, current_tramway_user if action_is_available.is_a?(Proc)
|
67
67
|
end
|
68
68
|
|
69
69
|
def check_action
|
@@ -73,7 +73,7 @@ module Tramway
|
|
73
73
|
project: (@application_engine || application_name),
|
74
74
|
role: role,
|
75
75
|
model_name: params[:model],
|
76
|
-
|
76
|
+
current_tramway_user: current_tramway_user
|
77
77
|
)
|
78
78
|
end.compact.uniq - [false]
|
79
79
|
|
@@ -94,17 +94,17 @@ module Tramway
|
|
94
94
|
project: (@application_engine || application_name),
|
95
95
|
model_name: params[:model]
|
96
96
|
)
|
97
|
-
head(:unauthorized) && return if !
|
97
|
+
head(:unauthorized) && return if !current_tramway_user && !action_is_open
|
98
98
|
end
|
99
99
|
|
100
|
-
def
|
100
|
+
def available_models_for_current_tramway_user
|
101
101
|
checking_roles.reduce([]) do |models, role|
|
102
102
|
models += ::Tramway::Api.available_models(role: role).map(&:to_s)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
def checking_roles
|
107
|
-
[:open,
|
107
|
+
[:open, current_tramway_user&.role].compact
|
108
108
|
end
|
109
109
|
|
110
110
|
protected
|
data/lib/tramway/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.1.6
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Engine for api
|