tramway-api 1.6.0.2 → 1.6.3.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 +4 -4
- data/app/controllers/tramway/api/application_controller.rb +6 -4
- data/app/controllers/tramway/api/v1/records_controller.rb +3 -1
- data/app/controllers/tramway/api/v1/user_tokens_controller.rb +1 -1
- data/app/controllers/tramway/api/v1/users_controller.rb +3 -2
- 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: dc3d2db65fc5b4b06905703a83e8652a7794f46cf2c28147cf0c39d95bb81f4f
|
4
|
+
data.tar.gz: 84d4b9f3f77bd968d75d2a512679647352c687193d26a2b30d909b58643cc3fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee82990f80e8692e5a1428ad0685ee0d17ff9ffa3acd5474716b3385fae07570be6d1d2a21fa3590b9351992eab8f318b3c0fa3359fc76fef0d1aef96ab58c92
|
7
|
+
data.tar.gz: 1fbe1b706291a8cfb0a04ea9e7ebeec5376032f2970d345424d18263d467d5d7da070dbb3f056482dd712e451d489e63bb314ed58ee0f1603f794d5c2fb32208
|
@@ -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
|
|
@@ -17,12 +17,14 @@ module Tramway
|
|
17
17
|
head :unauthorized
|
18
18
|
end
|
19
19
|
|
20
|
-
protected
|
21
|
-
|
22
20
|
def authenticate
|
23
|
-
return
|
21
|
+
return if current_user || params[:user_based_model].in?(Tramway::Api.user_based_models)
|
22
|
+
|
23
|
+
unauthorized
|
24
24
|
end
|
25
25
|
|
26
|
+
protected
|
27
|
+
|
26
28
|
def auth_token
|
27
29
|
if entity.respond_to? :to_token_payload
|
28
30
|
::Knock::AuthToken.new payload: entity.to_token_payload
|
@@ -69,7 +69,9 @@ module Tramway::Api::V1
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def authenticate_user_if_needed
|
72
|
-
|
72
|
+
if action_name.in?(Tramway::Api.available_models[model_class.to_s][:closed]&.map(&:to_s) || []) && !current_user
|
73
|
+
head(:unauthorized) && return
|
74
|
+
end
|
73
75
|
end
|
74
76
|
|
75
77
|
def model_class
|
@@ -9,13 +9,14 @@ class Tramway::Api::V1::UsersController < ::Tramway::Api::V1::ApplicationControl
|
|
9
9
|
def create
|
10
10
|
user_form = sign_up_form_class_name(user_based_model).new user_based_model.new
|
11
11
|
# Implement JSON API spec here
|
12
|
-
if user_form.submit snake_case params[
|
12
|
+
if user_form.submit snake_case params[:data][:attributes]
|
13
13
|
token = ::Knock::AuthToken.new(payload: { sub: user_form.model.uid }).token
|
14
14
|
# FIXME: refactor this bullshit
|
15
15
|
serialized_user = OpenStruct.new(
|
16
16
|
user_form.model.attributes.merge(
|
17
17
|
authentication_token: token,
|
18
|
-
|
18
|
+
uid: user_form.model.uid,
|
19
|
+
id: user_form.model.id
|
19
20
|
)
|
20
21
|
)
|
21
22
|
render json: serialized_user, status: :created
|
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.6.
|
4
|
+
version: 1.6.3.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:
|
11
|
+
date: 2020-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|