tramway-api 1.6.2 → 1.7.0.2

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: f922c7476e068d750206e1c8d1efd032ea2057c91840d4855c3cb49119a930f9
4
- data.tar.gz: 548da8c04040747f5d7628f54a77d90d1f0fcd5773d418d322137dbe3c70b07e
3
+ metadata.gz: 2f45730faad28566a38ee77ba298050f2e38b805dcd5aed36e6d479ee37604cb
4
+ data.tar.gz: 62543c93079ee5496602fe5454d0f909714d7ba2ed267e29ca617d908d0d3111
5
5
  SHA512:
6
- metadata.gz: edf68c18caac058f083fe6309c1efc9a96a33db6b55e319781b30891aaa4de1a555dce9fde68d0b453c6b2bd91959fea0782e73317142a8642995624c2b56c4e
7
- data.tar.gz: 74cb91244809c76c03442491c2689dfc1832664d3ceef4d685579b82b70cba6bf84c7bd45b5f5e4d3a71593893842f0493b52e2414ff14f3f062e48b081eff1f
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.find params[:id]
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.find params[:id]
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.find params[:id]
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
- head :unauthorized and return if action_name.in?(Tramway::Api.available_models[model_class.to_s][:closed]&.map(&:to_s) || []) && !current_user
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
- uid: @entity.uid,
12
- id: @entity.id
11
+ uuid: @entity.uuid
13
12
  }
14
13
  }, status: :created
15
14
  else
16
- not_found
15
+ unauthorized
17
16
  end
18
17
  end
19
18
  end
@@ -3,6 +3,12 @@
3
3
  class Tramway::Api::V1::ApplicationSerializer < ActiveModel::Serializer
4
4
  include ::Tramway::Core::Concerns::AttributesDecoratorHelper
5
5
 
6
+ attribute :id
7
+
8
+ def id
9
+ object.uuid
10
+ end
11
+
6
12
  def created_at
7
13
  object.created_at.iso8601
8
14
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Api
5
- VERSION = '1.6.2'
5
+ VERSION = '1.7.0.2'
6
6
  end
7
7
  end
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.6.2
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: 2019-11-24 00:00:00.000000000 Z
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