intercom-rails 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc
CHANGED
@@ -45,6 +45,23 @@ e.g.
|
|
45
45
|
:plan => "Pro",
|
46
46
|
:dashboard_page => 'http://dashboard.example.com/user-id'
|
47
47
|
|
48
|
+
=== secure mode
|
49
|
+
|
50
|
+
Pass in a second argument to intercom_script_tag, a hash containing the secret, like so:
|
51
|
+
|
52
|
+
<% if logged_in? %>
|
53
|
+
<%= intercom_script_tag({
|
54
|
+
:app_id => 'your-app-id'
|
55
|
+
:user_id => current_user.id
|
56
|
+
:email => current_user.email
|
57
|
+
:name => current_user.name
|
58
|
+
:created_at => current_user.created_at
|
59
|
+
},
|
60
|
+
{:secret => 'your-apps-secret'}
|
61
|
+
) %>
|
62
|
+
<% end %>
|
63
|
+
|
64
|
+
|
48
65
|
See {IntercomRails::ScriptTagHelper} for more details.
|
49
66
|
|
50
67
|
== Contributors
|
@@ -53,4 +70,4 @@ See {IntercomRails::ScriptTagHelper} for more details.
|
|
53
70
|
|
54
71
|
== License
|
55
72
|
|
56
|
-
This project rocks and uses MIT-LICENSE.
|
73
|
+
This project rocks and uses MIT-LICENSE.
|
@@ -30,7 +30,7 @@ module IntercomRails
|
|
30
30
|
# ) %>
|
31
31
|
def intercom_script_tag(user_details, options={})
|
32
32
|
if options[:secret]
|
33
|
-
secret_string = "#{options[:secret]}#{user_details[:
|
33
|
+
secret_string = "#{options[:secret]}#{user_details[:id].blank? ? user_details[:email] : user_details[:id]}"
|
34
34
|
user_details[:user_hash] = Digest::SHA1.hexdigest(secret_string)
|
35
35
|
end
|
36
36
|
intercom_settings = user_details.merge({:widget => options[:widget]}).with_indifferent_access
|
@@ -25,5 +25,6 @@ class IntercomRailsTest < MiniTest::Unit::TestCase
|
|
25
25
|
def test_secure_mode
|
26
26
|
assert_match(/.user_hash.\s*:\s*"#{Digest::SHA1.hexdigest('abcdefgh' + 'ciaran@intercom.io')}"/, intercom_script_tag({:email => "ciaran@intercom.io"}, {:secret => 'abcdefgh'}))
|
27
27
|
assert_match(/.user_hash.\s*:\s*"#{Digest::SHA1.hexdigest('abcdefgh' + '1234')}"/, intercom_script_tag({:id => 1234}, {:secret => 'abcdefgh'}))
|
28
|
+
assert_match(/.user_hash.\s*:\s*"#{Digest::SHA1.hexdigest('abcdefgh' + '1234')}"/, intercom_script_tag({:id => 1234, :email => "ciaran@intercom.io"}, {:secret => 'abcdefgh'}))
|
28
29
|
end
|
29
30
|
end
|