intercom-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
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[:email].blank? ? user_details[:id] : user_details[:email]}"
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
@@ -1,3 +1,3 @@
1
1
  module IntercomRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intercom-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: