diff --git a/intercom/templates/intercom/_intercom_js.html b/intercom/templates/intercom/_intercom_js.html
index 2567590..2bec399 100644
--- a/intercom/templates/intercom/_intercom_js.html
+++ b/intercom/templates/intercom/_intercom_js.html
@@ -1,9 +1,10 @@
{% if email %}
-
+
{% endif %}
diff --git a/intercom/templatetags/intercom_tags.py b/intercom/templatetags/intercom_tags.py
index 51b7eed..780be48 100644
--- a/intercom/templatetags/intercom_tags.py
+++ b/intercom/templatetags/intercom_tags.py
@@ -11,23 +11,23 @@
@register.inclusion_tag("intercom/_intercom_js.html")
def intercom_js(user):
- if hasattr(settings, "INTERCOM_APP_ID") and user.is_authenticated():
- if hasattr(settings, "INTERCOM_USER_HASH_KEY"):
- user_hash = sha_constructor(settings.INTERCOM_USER_HASH_KEY + user.email).hexdigest()
- else:
- user_hash = None
-
- custom_data = {}
- for app in getattr(settings, "INTERCOM_APPS", []):
- m = __import__(app + ".intercom", globals(), locals(), ["intercom"])
- custom_data.update(m.custom_data(user))
-
- return {
- "app_id": settings.INTERCOM_APP_ID,
- "email": user.email,
- "user_hash": user_hash,
- "created_at": int(time.mktime(user.date_joined.timetuple())),
- "custom_data": simplejson.dumps(custom_data, ensure_ascii=False)
- }
- else:
+ if not (hasattr(settings, "INTERCOM_APP_ID") and user.is_authenticated()):
return {}
+
+ if hasattr(settings, "INTERCOM_USER_HASH_KEY"):
+ user_hash = sha_constructor(settings.INTERCOM_USER_HASH_KEY + user.id).hexdigest()
+ else:
+ user_hash = None
+
+ custom_data = {}
+ for app in getattr(settings, "INTERCOM_APPS", []):
+ m = __import__(app + ".intercom", globals(), locals(), ["intercom"])
+ custom_data.update(m.custom_data(user))
+
+ return {
+ "app_id": settings.INTERCOM_APP_ID,
+ "email": user.email,
+ "user_hash": user_hash,
+ "created_at": int(time.mktime(user.date_joined.timetuple())),
+ "custom_data": simplejson.dumps(custom_data, ensure_ascii=False)
+ }