From 3c5141e46da34894dcb52989489a17890d5ddde7 Mon Sep 17 00:00:00 2001
From: Lloyd Hilaiel <lloyd@hilaiel.com>
Date: Thu, 18 Aug 2011 15:16:07 +0300
Subject: [PATCH] add debug logging to am_authed wsapi.  issue #74

---
 browserid/lib/wsapi.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/browserid/lib/wsapi.js b/browserid/lib/wsapi.js
index fe5033c6f..ef14ecb61 100644
--- a/browserid/lib/wsapi.js
+++ b/browserid/lib/wsapi.js
@@ -253,10 +253,16 @@ function setup(app) {
     // if they're authenticated for an email address that we don't know about,
     // then we should purge the stored cookie
     if (!isAuthed(req)) {
+      logger.debug("user is not authenticated");
       resp.json(false);
     } else {
       db.emailKnown(req.session.authenticatedUser, function (known) {
-        if (!known) req.session = {}
+        if (!known) {
+          logger.debug("user is authenticated with an email that doesn't exist in the database");
+          req.session = {};
+        } else {
+          logger.debug("user is authenticated");
+        }
         resp.json(known);
       });
     }
-- 
GitLab