From a74764c833868e738043de3850d413c6cabea46e Mon Sep 17 00:00:00 2001
From: Neil Lalonde <neillalonde@gmail.com>
Date: Wed, 19 Mar 2014 13:31:17 -0400
Subject: [PATCH] Log when facebook doesn't provide an email address

---
 app/models/user_history.rb         | 3 ++-
 lib/auth/facebook_authenticator.rb | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/app/models/user_history.rb b/app/models/user_history.rb
index 1188e62db..6747a2842 100644
--- a/app/models/user_history.rb
+++ b/app/models/user_history.rb
@@ -22,7 +22,8 @@ class UserHistory < ActiveRecord::Base
                            :notified_about_sequential_replies,
                            :notified_about_dominating_topic,
                            :suspend_user,
-                           :unsuspend_user)
+                           :unsuspend_user,
+                           :facebook_no_email)
   end
 
   # Staff actions is a subset of all actions, used to audit actions taken by staff users.
diff --git a/lib/auth/facebook_authenticator.rb b/lib/auth/facebook_authenticator.rb
index e5e203971..05b6c7b4b 100644
--- a/lib/auth/facebook_authenticator.rb
+++ b/lib/auth/facebook_authenticator.rb
@@ -24,6 +24,13 @@ class Auth::FacebookAuthenticator < Auth::Authenticator
       FacebookUserInfo.create({user_id: result.user.id}.merge(facebook_hash))
     end
 
+    if email.blank?
+      UserHistory.create(
+        action: UserHistory.actions[:facebook_no_email],
+        details: "name: #{facebook_hash[:name]}, facebook_user_id: #{facebook_hash[:facebook_user_id]}"
+      )
+    end
+
     result
   end