Class: Api::Vendor::V1::Dianping::BaseController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Api::Vendor::V1::Dianping::BaseController
- Includes:
- Concerns::IntegrationTestHelpers, ResponseCacheConcern
- Defined in:
- app/controllers/api/vendor/v1/dianping/base_controller.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#vendor ⇒ Object
readonly
Returns the value of attribute vendor.
Instance Method Summary collapse
Methods included from ResponseCacheConcern
Methods inherited from ApplicationController
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
Methods included from LogrageCustomLogger
Methods included from ControllerHelpers
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Attribute Details
#vendor ⇒ Object (readonly)
Returns the value of attribute vendor.
8 9 10 |
# File 'app/controllers/api/vendor/v1/dianping/base_controller.rb', line 8 def vendor @vendor end |
Instance Method Details
#authenticate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/api/vendor/v1/dianping/base_controller.rb', line 10 def authenticate vendor_name = ApiVendorV1::Constants::DIANPING_VENDOR_NAME raw_body = request.raw_post decoded_body = CGI.unescape(raw_body) parsed_body = JSON.parse(decoded_body) sign = parsed_body['sign'] data = parsed_body['data'] if data.blank? APMErrorHandler.report("#{self.class}: Missing data", vendor: vendor_name) return render json: { code: 400, msg: 'Missing data' }, status: :bad_request end unless valid_signature?(sign, data) APMErrorHandler.report("#{self.class}: Sign verification failed", vendor: vendor_name) return render json: { code: 501, msg: 'Sign verification failed' }, status: :not_implemented end decoded_data = Base64.decode64(data) @parsed_data = JSON.parse(decoded_data) end |