Chatwoot/app/controllers/api/v1/webhooks_controller.rb
Pranav Raj S 2c144d5ad3
Setup Circle CI, add brakeman config (#13)
* Add circle ci config

* Change config to fix tests

* Update config

* Fix eslint command, add brakeman
2019-08-21 12:59:56 +05:30

27 lines
695 B
Ruby

class Api::V1::WebhooksController < ApplicationController
skip_before_action :authenticate_user!, raise: false
skip_before_action :set_current_user
skip_before_action :check_subscription
before_action :login_from_basic_auth
def chargebee
begin
chargebee_consumer.consume
head :ok
rescue => e
Raven.capture_exception(e)
head :ok
end
end
private
def login_from_basic_auth
authenticate_or_request_with_http_basic do |username, password|
username == ENV['CHARGEBEE_WEBHOOK_USERNAME'] && password == ENV['CHARGEBEE_WEBHOOK_PASSWORD']
end
end
def chargebee_consumer
@consumer ||= ::Webhooks::Chargebee.new(params)
end
end