fix: Ensure HMAC mandatory when enabled (#3350)

Add missing condition checking if HMAC is mandatory.

Fixes #3349
This commit is contained in:
sarzynski
2021-11-11 05:18:38 +01:00
committed by GitHub
parent c0f5a59cf8
commit b3e313a200
2 changed files with 51 additions and 2 deletions

View File

@@ -14,8 +14,9 @@ class Api::V1::Widget::ContactsController < Api::V1::Widget::BaseController
private
def process_hmac
return if params[:identifier_hash].blank?
raise StandardError, 'HMAC failed: Invalid Identifier Hash Provided' unless valid_hmac?
return if params[:identifier_hash].blank? && !@web_widget.hmac_mandatory
render json: { error: 'HMAC failed: Invalid Identifier Hash Provided' }, status: :unauthorized unless valid_hmac?
@contact_inbox.update(hmac_verified: true)
end