-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MNO-271] Add support for Intercom secure mode
Intercom need a server side generated HMAC of the user_id or email when secure mode is enabled. See: https://docs.intercom.com/configure-intercom-for-your-product-or-site/staying-secure/enable-secure-mode-on-your-web-product
- Loading branch information
Olivier Brisse
committed
Sep 21, 2016
1 parent
a4366b4
commit bde42a4
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'openssl' | ||
|
||
module MnoEnterprise::Concerns::Models::IntercomUser | ||
extend ActiveSupport::Concern | ||
|
||
#================================================================== | ||
# Included methods | ||
#================================================================== | ||
# 'included do' causes the included code to be evaluated in the | ||
# context where it is included rather than being executed in the module's context | ||
included do | ||
if MnoEnterprise.intercom_enabled? | ||
# Return intercom user hash | ||
# This is used in secure mode | ||
def intercom_user_hash | ||
OpenSSL::HMAC.hexdigest('sha256', MnoEnterprise.intercom_api_secret, (self.id || self.email).to_s) | ||
end | ||
end | ||
end | ||
|
||
#================================================================== | ||
# Class methods | ||
#================================================================== | ||
module ClassMethods | ||
# def some_class_method | ||
# 'some text' | ||
# end | ||
end | ||
|
||
#================================================================== | ||
# Instance methods | ||
#================================================================== | ||
end |