thecore_api 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1af0a793ef25d9d3d8678683c1b9b016d85d41b8a206ea2a73ea7c2b8182901e
4
- data.tar.gz: ba9b80c4635788726dcc8e4c0f25109f1c401fdda25cf59b99667846ffef97cb
3
+ metadata.gz: 77b761b925780fcc6028197f2bbb1cd181b0a4f65e59e59d7c3e44c49d075038
4
+ data.tar.gz: 88559518468dcffe114a79d6a323a1f5b7ab0964d7036fbf09c14a6a37b719f1
5
5
  SHA512:
6
- metadata.gz: 8b96365c02d73622755d5a9ddd7ad8414eaca91188c06715cd79d7bc80d752c63578127751676c31f5b18448fb1cb48248eae3bb84455dacc2bac503855935e2
7
- data.tar.gz: d83ebaa1e04526cb60bccade5f21c28b1078ae44acd18200d9f06ce5ac99a2c8842df8eb43da5b07b933fe95097d2ca55b53b6f7333ff5a2f41b4d27d991bd22
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, :token, :available_roles, :check, :translations, :schema ]
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
- # Rails.logger.debug exception.errors.inspect
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 = user_email && User.find_by(email: user_email)
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
@@ -1,3 +1,3 @@
1
1
  module ThecoreApi
2
- VERSION = "1.4.3".freeze
2
+ VERSION = "1.4.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni