{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/comments/56919849","id":56919849,"diff_hunk":"@@ -891,12 +893,37 @@ module.exports = function (\n       handler: function (request, reply) {\n         log.begin('Account.RecoveryEmailStatus', request)\n         var sessionToken = request.auth.credentials\n-        reply(\n-          {\n-            email: sessionToken.email,\n-            verified: sessionToken.emailVerified\n+\n+        cleanUpIfAccountInvalid()\n+          .then(createResponse)\n+          .done(reply, reply)\n+\n+        function cleanUpIfAccountInvalid() {\n+          // Some historical bugs mean we've allowed creation\n+          // of accounts with invalid email addresses. These\n+          // can never be verified, so the best we can do is\n+          // to delete them so the browser will stop polling.\n+          if (!sessionToken.emailVerified) {\n+            if (!validators.isValidEmailAddress(sessionToken.email)) {\n+              return db.deleteAccount(sessionToken)\n+                .then(\n+                  function () {\n+                    // Act as though we deleted the account asynchronously\n+                    // and caused the sessionToken to become invalid.\n+                    throw error.invalidToken()\n+                  }","path":"lib/routes/account.js","position":37,"original_position":37,"commit_id":"523339179b97707d2baacee4ccc93e17931a536d","original_commit_id":"523339179b97707d2baacee4ccc93e17931a536d","user":{"login":"rfk","id":34695,"avatar_url":"https://avatars.githubusercontent.com/u/34695?v=3","gravatar_id":"","url":"https://api.github.com/users/rfk","html_url":"https://github.com/rfk","followers_url":"https://api.github.com/users/rfk/followers","following_url":"https://api.github.com/users/rfk/following{/other_user}","gists_url":"https://api.github.com/users/rfk/gists{/gist_id}","starred_url":"https://api.github.com/users/rfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfk/subscriptions","organizations_url":"https://api.github.com/users/rfk/orgs","repos_url":"https://api.github.com/users/rfk/repos","events_url":"https://api.github.com/users/rfk/events{/privacy}","received_events_url":"https://api.github.com/users/rfk/received_events","type":"User","site_admin":false},"body":"Related browser behaviour bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1226449\r\n\r\nI tested in release and nightly by signing up with a new account, then deleting it before verifying.  Release just stayed in the \"you need to verify your email\" state, and I'm not sure whether it stopped polling.  Nightly discovered the deletion and reverted to \"sign in the sync\" state.  Both of these seem OK and are no worse than current behaviour.\r\n\r\nI *believe* the behaviour should be the same as what you'd get if you entered an email that bounced, because you'd get the same effect - the account is deleted and your session token becomes invalid.","created_at":"2016-03-22T00:16:39Z","updated_at":"2016-03-22T00:16:39Z","html_url":"https://github.com/mozilla/fxa-auth-server/pull/1221#discussion_r56919849","pull_request_url":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/1221","_links":{"self":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/comments/56919849"},"html":{"href":"https://github.com/mozilla/fxa-auth-server/pull/1221#discussion_r56919849"},"pull_request":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/1221"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/1221","id":63520719,"html_url":"https://github.com/mozilla/fxa-auth-server/pull/1221","diff_url":"https://github.com/mozilla/fxa-auth-server/pull/1221.diff","patch_url":"https://github.com/mozilla/fxa-auth-server/pull/1221.patch","issue_url":"https://api.github.com/repos/mozilla/fxa-auth-server/issues/1221","number":1221,"state":"open","locked":false,"title":"fix(email): Clean up accounts with invalid emails on status poll.","user":{"login":"rfk","id":34695,"avatar_url":"https://avatars.githubusercontent.com/u/34695?v=3","gravatar_id":"","url":"https://api.github.com/users/rfk","html_url":"https://github.com/rfk","followers_url":"https://api.github.com/users/rfk/followers","following_url":"https://api.github.com/users/rfk/following{/other_user}","gists_url":"https://api.github.com/users/rfk/gists{/gist_id}","starred_url":"https://api.github.com/users/rfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfk/subscriptions","organizations_url":"https://api.github.com/users/rfk/orgs","repos_url":"https://api.github.com/users/rfk/repos","events_url":"https://api.github.com/users/rfk/events{/privacy}","received_events_url":"https://api.github.com/users/rfk/received_events","type":"User","site_admin":false},"body":"Potentially fixes #1219, /cc @jrgm; @philbooth mind an r?\r\n\r\nThis proved tricky to test using the current test infrastructure, because the desired logic requires the creation of a strange database state.  I took a new approach based on mocking out everything but the route-handling code itself, which made the specific change in this PR easier to test, but may have other downsides overall.  What do you think @philbooth?  If we like it, we could work on slowly refactoring other routes to have more unit-test-style tests like this as well.","created_at":"2016-03-21T04:17:46Z","updated_at":"2016-03-22T00:16:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d4e51916e6611d7b48091b51108f66bae74e98b","assignee":{"login":"jrgm","id":758162,"avatar_url":"https://avatars.githubusercontent.com/u/758162?v=3","gravatar_id":"","url":"https://api.github.com/users/jrgm","html_url":"https://github.com/jrgm","followers_url":"https://api.github.com/users/jrgm/followers","following_url":"https://api.github.com/users/jrgm/following{/other_user}","gists_url":"https://api.github.com/users/jrgm/gists{/gist_id}","starred_url":"https://api.github.com/users/jrgm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrgm/subscriptions","organizations_url":"https://api.github.com/users/jrgm/orgs","repos_url":"https://api.github.com/users/jrgm/repos","events_url":"https://api.github.com/users/jrgm/events{/privacy}","received_events_url":"https://api.github.com/users/jrgm/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/1221/commits","review_comments_url":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/1221/comments","review_comment_url":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/fxa-auth-server/issues/1221/comments","statuses_url":"https://api.github.com/repos/mozilla/fxa-auth-server/statuses/523339179b97707d2baacee4ccc93e17931a536d","head":{"label":"mozilla:cleanup-invalid-accounts-on-status-poll","ref":"cleanup-invalid-accounts-on-status-poll","sha":"523339179b97707d2baacee4ccc93e17931a536d","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":10041891,"name":"fxa-auth-server","full_name":"mozilla/fxa-auth-server","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/fxa-auth-server","description":"The Firefox Accounts authentication server.","fork":false,"url":"https://api.github.com/repos/mozilla/fxa-auth-server","forks_url":"https://api.github.com/repos/mozilla/fxa-auth-server/forks","keys_url":"https://api.github.com/repos/mozilla/fxa-auth-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/fxa-auth-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/fxa-auth-server/teams","hooks_url":"https://api.github.com/repos/mozilla/fxa-auth-server/hooks","issue_events_url":"https://api.github.com/repos/mozilla/fxa-auth-server/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/fxa-auth-server/events","assignees_url":"https://api.github.com/repos/mozilla/fxa-auth-server/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/fxa-auth-server/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/fxa-auth-server/tags","blobs_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/fxa-auth-server/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/fxa-auth-server/languages","stargazers_url":"https://api.github.com/repos/mozilla/fxa-auth-server/stargazers","contributors_url":"https://api.github.com/repos/mozilla/fxa-auth-server/contributors","subscribers_url":"https://api.github.com/repos/mozilla/fxa-auth-server/subscribers","subscription_url":"https://api.github.com/repos/mozilla/fxa-auth-server/subscription","commits_url":"https://api.github.com/repos/mozilla/fxa-auth-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/fxa-auth-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/fxa-auth-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/fxa-auth-server/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/fxa-auth-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/fxa-auth-server/merges","archive_url":"https://api.github.com/repos/mozilla/fxa-auth-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/fxa-auth-server/downloads","issues_url":"https://api.github.com/repos/mozilla/fxa-auth-server/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/fxa-auth-server/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/fxa-auth-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/fxa-auth-server/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/fxa-auth-server/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/fxa-auth-server/deployments","created_at":"2013-05-13T21:42:48Z","updated_at":"2016-03-16T10:42:43Z","pushed_at":"2016-03-21T08:55:57Z","git_url":"git://github.com/mozilla/fxa-auth-server.git","ssh_url":"git@github.com:mozilla/fxa-auth-server.git","clone_url":"https://github.com/mozilla/fxa-auth-server.git","svn_url":"https://github.com/mozilla/fxa-auth-server","homepage":"https://wiki.mozilla.org/Identity/Firefox_Accounts","size":4374,"stargazers_count":230,"watchers_count":230,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"open_issues_count":39,"forks":58,"open_issues":39,"watchers":230,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"8f581d33f067cd81e7e0f0971e0c3dfad32e9405","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":10041891,"name":"fxa-auth-server","full_name":"mozilla/fxa-auth-server","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/fxa-auth-server","description":"The Firefox Accounts authentication server.","fork":false,"url":"https://api.github.com/repos/mozilla/fxa-auth-server","forks_url":"https://api.github.com/repos/mozilla/fxa-auth-server/forks","keys_url":"https://api.github.com/repos/mozilla/fxa-auth-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/fxa-auth-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/fxa-auth-server/teams","hooks_url":"https://api.github.com/repos/mozilla/fxa-auth-server/hooks","issue_events_url":"https://api.github.com/repos/mozilla/fxa-auth-server/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/fxa-auth-server/events","assignees_url":"https://api.github.com/repos/mozilla/fxa-auth-server/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/fxa-auth-server/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/fxa-auth-server/tags","blobs_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/fxa-auth-server/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/fxa-auth-server/languages","stargazers_url":"https://api.github.com/repos/mozilla/fxa-auth-server/stargazers","contributors_url":"https://api.github.com/repos/mozilla/fxa-auth-server/contributors","subscribers_url":"https://api.github.com/repos/mozilla/fxa-auth-server/subscribers","subscription_url":"https://api.github.com/repos/mozilla/fxa-auth-server/subscription","commits_url":"https://api.github.com/repos/mozilla/fxa-auth-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/fxa-auth-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/fxa-auth-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/fxa-auth-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/fxa-auth-server/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/fxa-auth-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/fxa-auth-server/merges","archive_url":"https://api.github.com/repos/mozilla/fxa-auth-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/fxa-auth-server/downloads","issues_url":"https://api.github.com/repos/mozilla/fxa-auth-server/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/fxa-auth-server/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/fxa-auth-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/fxa-auth-server/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/fxa-auth-server/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/fxa-auth-server/deployments","created_at":"2013-05-13T21:42:48Z","updated_at":"2016-03-16T10:42:43Z","pushed_at":"2016-03-21T08:55:57Z","git_url":"git://github.com/mozilla/fxa-auth-server.git","ssh_url":"git@github.com:mozilla/fxa-auth-server.git","clone_url":"https://github.com/mozilla/fxa-auth-server.git","svn_url":"https://github.com/mozilla/fxa-auth-server","homepage":"https://wiki.mozilla.org/Identity/Firefox_Accounts","size":4374,"stargazers_count":230,"watchers_count":230,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"open_issues_count":39,"forks":58,"open_issues":39,"watchers":230,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/1221"},"html":{"href":"https://github.com/mozilla/fxa-auth-server/pull/1221"},"issue":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/issues/1221"},"comments":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/issues/1221/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/1221/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/pulls/1221/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/fxa-auth-server/statuses/523339179b97707d2baacee4ccc93e17931a536d"}}}}