thecore_api 1.4.3 → 1.4.4
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/api/v1/base_controller.rb +5 -4
- data/lib/thecore_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b761b925780fcc6028197f2bbb1cd181b0a4f65e59e59d7c3e44c49d075038
|
4
|
+
data.tar.gz: 88559518468dcffe114a79d6a323a1f5b7ab0964d7036fbf09c14a6a37b719f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36d00b25f1abc7c32e27008bb868b8e6da53af67c7539574650ea38a9ac3b41cf91cb924685c7543861130048437303e5c2ade9539d3e9476a65911c82ff8822
|
7
|
+
data.tar.gz: 134a1e19be4ae5e2a5420e04b55b2638c7ff79c58507429bc6ae4c3501be208ab879249f8b3e22edc798c95a847f61982c60468e8b065738f4d6f503efcb6d0c
|
@@ -22,7 +22,7 @@ class Api::V1::BaseController < ActionController::API
|
|
22
22
|
before_action :destroy_session
|
23
23
|
|
24
24
|
before_action :authenticate_user!
|
25
|
-
before_action :find_model, except: [ :version, :
|
25
|
+
before_action :find_model, except: [ :version, :available_roles, :translations, :schema ]
|
26
26
|
before_action :find_record, only: [ :show, :update, :destroy ]
|
27
27
|
|
28
28
|
rescue_from ActiveRecord::StatementInvalid, with: :unauthenticated!
|
@@ -201,9 +201,9 @@ class Api::V1::BaseController < ActionController::API
|
|
201
201
|
end
|
202
202
|
|
203
203
|
def invalid! exception
|
204
|
-
#
|
204
|
+
# puts "ISPEZIONI: #{exception.record.errors.inspect}"
|
205
205
|
# render json: { error: exception }, status: 422
|
206
|
-
api_error status: 422, errors: exception
|
206
|
+
api_error status: 422, errors: exception.record.errors
|
207
207
|
end
|
208
208
|
|
209
209
|
def api_error(status: 500, errors: [])
|
@@ -254,7 +254,7 @@ class Api::V1::BaseController < ActionController::API
|
|
254
254
|
token, options = ActionController::HttpAuthentication::Token.token_and_options(request)
|
255
255
|
|
256
256
|
user_email = options.blank? ? nil : options[:email]
|
257
|
-
user =
|
257
|
+
user = User.find_by(email: user_email)
|
258
258
|
|
259
259
|
return unauthenticated! if user.blank? || !ActiveSupport::SecurityUtils.secure_compare(user.authentication_token, token)
|
260
260
|
@current_user = user
|
@@ -269,6 +269,7 @@ class Api::V1::BaseController < ActionController::API
|
|
269
269
|
|
270
270
|
def find_model path=nil
|
271
271
|
# Find the name of the model from controller
|
272
|
+
path ||= params[:path]
|
272
273
|
@singular_controller = (path.presence || controller_name).singularize.to_sym
|
273
274
|
@model = (path.presence || controller_path).classify.constantize rescue controller_name.classify.constantize
|
274
275
|
end
|
data/lib/thecore_api/version.rb
CHANGED