tramway-api 1.6.2 → 1.7.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/tramway/api/application_controller.rb +2 -1
- data/app/controllers/tramway/api/v1/records_controller.rb +7 -4
- data/app/controllers/tramway/api/v1/user_tokens_controller.rb +2 -3
- data/app/serializers/tramway/api/v1/application_serializer.rb +6 -0
- data/lib/tramway/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f45730faad28566a38ee77ba298050f2e38b805dcd5aed36e6d479ee37604cb
|
4
|
+
data.tar.gz: 62543c93079ee5496602fe5454d0f909714d7ba2ed267e29ca617d908d0d3111
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 315444c1714b3d0076a0e040eee18bcd7b5c7366e8a391258bd2f082e33d4fc970a79ff0ac3c01d5efc5a6d06027548578052e4e82be59befd11a3bd58ae127b
|
7
|
+
data.tar.gz: 1c69b4053f98bff5105a1d5271d21c075e876b61f42aebb7443f4c86be62d91185456b04c2376c9fa1b396564acdba9cc6d3c8f14b46bd95e6f9057e92fbf438
|
@@ -5,7 +5,7 @@ module Tramway
|
|
5
5
|
class ApplicationController < ::Tramway::Core::ApplicationController
|
6
6
|
include ::Knock::Authenticable
|
7
7
|
protect_from_forgery with: :null_session, if: proc { |c| c.request.format == 'application/json' }
|
8
|
-
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
8
|
+
rescue_from ActiveRecord::RecordNotFound, with: :not_found if Rails.env.production?
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -19,6 +19,7 @@ module Tramway
|
|
19
19
|
|
20
20
|
def authenticate
|
21
21
|
return if current_user || params[:user_based_model].in?(Tramway::Api.user_based_models)
|
22
|
+
|
22
23
|
unauthorized
|
23
24
|
end
|
24
25
|
|
@@ -18,6 +18,7 @@ module Tramway::Api::V1
|
|
18
18
|
def create
|
19
19
|
record_form = form_class.new model_class.new
|
20
20
|
if record_form.submit snake_case params[:data][:attributes]
|
21
|
+
record_form.model.reload
|
21
22
|
render json: record_form.model,
|
22
23
|
serializer: serializer_class,
|
23
24
|
include: '*',
|
@@ -28,7 +29,7 @@ module Tramway::Api::V1
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def update
|
31
|
-
record_form = form_class.new model_class.active.
|
32
|
+
record_form = form_class.new model_class.active.find_by uuid: params[:id]
|
32
33
|
if record_form.submit snake_case params[:data][:attributes]
|
33
34
|
render json: record_form.model,
|
34
35
|
serializer: serializer_class,
|
@@ -40,7 +41,7 @@ module Tramway::Api::V1
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def show
|
43
|
-
record = model_class.active.
|
44
|
+
record = model_class.active.find_by uuid: params[:id]
|
44
45
|
render json: record,
|
45
46
|
serializer: serializer_class,
|
46
47
|
include: '*',
|
@@ -48,7 +49,7 @@ module Tramway::Api::V1
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def destroy
|
51
|
-
record = model_class.active.
|
52
|
+
record = model_class.active.find_by uuid: params[:id]
|
52
53
|
record.remove
|
53
54
|
render json: record,
|
54
55
|
serializer: serializer_class,
|
@@ -69,7 +70,9 @@ module Tramway::Api::V1
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def authenticate_user_if_needed
|
72
|
-
|
73
|
+
if action_name.in?(Tramway::Api.available_models[model_class.to_s][:closed]&.map(&:to_s) || []) && !current_user
|
74
|
+
head(:unauthorized) && return
|
75
|
+
end
|
73
76
|
end
|
74
77
|
|
75
78
|
def model_class
|
@@ -8,12 +8,11 @@ class Tramway::Api::V1::UserTokensController < ::Tramway::Api::V1::ApplicationCo
|
|
8
8
|
auth_token: token,
|
9
9
|
user: {
|
10
10
|
email: @entity.email,
|
11
|
-
|
12
|
-
id: @entity.id
|
11
|
+
uuid: @entity.uuid
|
13
12
|
}
|
14
13
|
}, status: :created
|
15
14
|
else
|
16
|
-
|
15
|
+
unauthorized
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
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: 1.
|
4
|
+
version: 1.7.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|