From 891dcd731325b8a7f5e477d52cb9f3a3a2a6a30a Mon Sep 17 00:00:00 2001
From: Lloyd Hilaiel <lloyd@hilaiel.com>
Date: Mon, 9 Jul 2012 20:45:17 -0600
Subject: [PATCH] rename the 'add email' email we send out to 'confirm', and
 use it in both the email addition case, and the email reverification case. 
 This is more about semantics than behavior change

---
 lib/email.js                                           | 10 +++++-----
 lib/static/email_templates/{add.ejs => confirm.ejs}    |  2 +-
 lib/static/views.js                                    |  8 +++++---
 lib/wsapi/stage_email.js                               |  2 +-
 lib/wsapi/stage_reverify.js                            |  2 +-
 resources/static/pages/js/start.js                     |  5 ++++-
 .../test/cases/pages/js/verify_secondary_address.js    |  2 +-
 resources/views/{add_email_address.ejs => confirm.ejs} |  0
 tests/cache-header-tests.js                            |  1 +
 tests/page-requests-test.js                            |  1 +
 10 files changed, 20 insertions(+), 13 deletions(-)
 rename lib/static/email_templates/{add.ejs => confirm.ejs} (66%)
 rename resources/views/{add_email_address.ejs => confirm.ejs} (100%)

diff --git a/lib/email.js b/lib/email.js
index 504c21f6e..13d24ffbb 100644
--- a/lib/email.js
+++ b/lib/email.js
@@ -45,10 +45,10 @@ const templates = {
     subject: _("Reset Persona password"), 
     template: fs.readFileSync(path.join(TEMPLATE_PATH, 'reset.ejs')),
   },
-  "add": {
-    landing: 'add_email_address',
+  "confirm": {
+    landing: 'confirm',
     subject: _("Confirm email address for Persona"), 
-    template: fs.readFileSync(path.join(TEMPLATE_PATH, 'add.ejs')),
+    template: fs.readFileSync(path.join(TEMPLATE_PATH, 'confirm.ejs')),
   }
 };
 
@@ -118,8 +118,8 @@ exports.sendNewUserEmail = function(email, site, secret, langContext) {
   doSend('new', email, site, secret, langContext);
 };
 
-exports.sendAddAddressEmail = function(email, site, secret, langContext) {
-  doSend('add', email, site, secret, langContext);
+exports.sendConfirmationEmail = function(email, site, secret, langContext) {
+  doSend('confirm', email, site, secret, langContext);
 };
 
 exports.sendForgotPasswordEmail = function(email, site, secret, langContext) {
diff --git a/lib/static/email_templates/add.ejs b/lib/static/email_templates/confirm.ejs
similarity index 66%
rename from lib/static/email_templates/add.ejs
rename to lib/static/email_templates/confirm.ejs
index fb928499b..ad8758855 100644
--- a/lib/static/email_templates/add.ejs
+++ b/lib/static/email_templates/confirm.ejs
@@ -3,7 +3,7 @@
 <%= format(gettext('Click to confirm this email address and automatically sign in to %s'), [site]) %>
 <%= link %>
 
-<%= format(gettext('Note: If you are NOT trying to sign into this website, please ignore this email.'), [site]) %>
+<%= gettext('Note: If you are NOT trying to sign into this website, please ignore this email.') %>
 
 <%= gettext('Thank you,') %>
 <%= gettext('The Persona team') %>
diff --git a/lib/static/views.js b/lib/static/views.js
index 4533cebac..957bfb09c 100644
--- a/lib/static/views.js
+++ b/lib/static/views.js
@@ -174,17 +174,19 @@ exports.setup = function(app) {
     });
   });
 
+  // This page can be removed a couple weeks after this code ships into production,
+  // we're leaving it here to not break outstanding emails
   app.get("/add_email_address", function(req,res) {
-    renderCachableView(req, res, 'add_email_address.ejs', {title: 'Verify Email Address', fullpage: false});
+    renderCachableView(req, res, 'confirm.ejs', {title: 'Verify Email Address', fullpage: false});
   });
 
 
   app.get("/reset_password", function(req,res) {
-    renderCachableView(req, res, 'add_email_address.ejs', {title: 'Reset Password'});
+    renderCachableView(req, res, 'confirm.ejs', {title: 'Reset Password'});
   });
 
   app.get("/confirm", function(req,res) {
-    renderCachableView(req, res, 'add_email_address.ejs', {title: 'Confirm Email'});
+    renderCachableView(req, res, 'confirm.ejs', {title: 'Confirm Email'});
   });
 
 
diff --git a/lib/wsapi/stage_email.js b/lib/wsapi/stage_email.js
index 6f4ede8f6..1e9d8cdb4 100644
--- a/lib/wsapi/stage_email.js
+++ b/lib/wsapi/stage_email.js
@@ -88,7 +88,7 @@ exports.process = function(req, res) {
 
             res.json({ success: true });
             // let's now kick out a verification email!
-            email.sendAddAddressEmail(req.body.email, req.body.site, secret, langContext);
+            email.sendConfirmationEmail(req.body.email, req.body.site, secret, langContext);
           });
         } catch(e) {
           // we should differentiate tween' 400 and 500 here.
diff --git a/lib/wsapi/stage_reverify.js b/lib/wsapi/stage_reverify.js
index 100e252fe..c43980210 100644
--- a/lib/wsapi/stage_reverify.js
+++ b/lib/wsapi/stage_reverify.js
@@ -60,7 +60,7 @@ exports.process = function(req, res) {
             
             res.json({ success: true });
             // let's now kick out a verification email!
-            email.sendAddAddressEmail(req.body.email, req.body.site, secret, langContext);
+            email.sendConfirmationEmail(req.body.email, req.body.site, secret, langContext);
           });
         } catch(e) {
           // we should differentiate tween' 400 and 500 here.
diff --git a/resources/static/pages/js/start.js b/resources/static/pages/js/start.js
index ed1f480e3..652c111db 100644
--- a/resources/static/pages/js/start.js
+++ b/resources/static/pages/js/start.js
@@ -26,7 +26,7 @@ $(function() {
       XHRDisableForm = modules.XHRDisableForm,
       Development = modules.Development,
       ANIMATION_TIME = 500,
-      checkCookiePaths = [ "/signin", "/signup", "/forgot", "/add_email_address", "/verify_email_address" ];
+      checkCookiePaths = [ "/signin", "/signup", "/forgot", "/add_email_address", "/confirm", "/verify_email_address" ];
 
 
   function shouldCheckCookies(path) {
@@ -148,6 +148,9 @@ $(function() {
     else if (path === "/add_email_address") {
       verifySecondaryAddress("verifyEmail");
     }
+    else if (path === "/confirm") {
+      verifySecondaryAddress("verifyEmail");
+    }
     else if (path === "/verify_email_address") {
       verifySecondaryAddress("verifyUser");
     }
diff --git a/resources/static/test/cases/pages/js/verify_secondary_address.js b/resources/static/test/cases/pages/js/verify_secondary_address.js
index f15227bc0..fcbbe8839 100644
--- a/resources/static/test/cases/pages/js/verify_secondary_address.js
+++ b/resources/static/test/cases/pages/js/verify_secondary_address.js
@@ -25,7 +25,7 @@
   module("pages/verify_secondary_address", {
     setup: function() {
       testHelpers.setup();
-      bid.Renderer.render("#page_head", "site/add_email_address", {});
+      bid.Renderer.render("#page_head", "site/confirm", {});
       $(".siteinfo,.password_entry").hide();
     },
     teardown: function() {
diff --git a/resources/views/add_email_address.ejs b/resources/views/confirm.ejs
similarity index 100%
rename from resources/views/add_email_address.ejs
rename to resources/views/confirm.ejs
diff --git a/tests/cache-header-tests.js b/tests/cache-header-tests.js
index 9649791ba..da97f1671 100755
--- a/tests/cache-header-tests.js
+++ b/tests/cache-header-tests.js
@@ -132,6 +132,7 @@ suite.addBatch({
   '/privacy': hasProperCacheHeaders('/privacy'),
   '/verify_email_address': hasProperCacheHeaders('/verify_email_address'),
   '/add_email_address': hasProperCacheHeaders('/add_email_address'),
+  '/confirm': hasProperCacheHeaders('/confirm'),
 //  '/pk': hasProperCacheHeaders('/pk'),
 //  '/.well-known/browserid': hasProperCacheHeaders('/.well-known/browserid')
 });
diff --git a/tests/page-requests-test.js b/tests/page-requests-test.js
index 2ae2100ab..a6fd57988 100755
--- a/tests/page-requests-test.js
+++ b/tests/page-requests-test.js
@@ -63,6 +63,7 @@ suite.addBatch({
   'GET /privacy':                respondsWith(200),
   'GET /verify_email_address':   respondsWith(200),
   'GET /add_email_address':      respondsWith(200),
+  'GET /confirm':                respondsWith(200),
   'GET /reset_password':         respondsWith(200),
   'GET /confirm':                respondsWith(200),
   'GET /idp_auth_complete':      respondsWith(200),
-- 
GitLab