From 6f1f962dc85a30cbcf2364de9ee4e2c1b3b742ef Mon Sep 17 00:00:00 2001
From: Shane Tomlinson <stomlinson@mozilla.com>
Date: Fri, 27 Jul 2012 17:45:06 +0100
Subject: [PATCH] If the user hits the /signin or /forgot pages while signed
 in, redirect them to the "/" page.

---
 resources/static/pages/js/start.js | 92 ++++++++++++++++--------------
 1 file changed, 49 insertions(+), 43 deletions(-)

diff --git a/resources/static/pages/js/start.js b/resources/static/pages/js/start.js
index 03f66f0ee..daa811f4c 100644
--- a/resources/static/pages/js/start.js
+++ b/resources/static/pages/js/start.js
@@ -130,50 +130,56 @@ $(function() {
     // instead just show the error message.
     if (!status) return;
 
-
-    if (!path || path === "/") {
-      bid.index();
-    }
-    else if (path === "/signin") {
-      var module = bid.signIn.create();
-      module.start({});
-    }
-    else if (path === "/forgot") {
-      var module = bid.forgot.create();
-      module.start({});
-    }
-    // START TRANSITION CODE
-    // add_email_address has been renamed to confirm. Once all outstanding
-    // emails are verified or expired, this can be removed. This change is
-    // scheduled to go into train-2012.07.20
-    else if (path === "/add_email_address") {
-      verifySecondaryAddress("verifyEmail");
-    }
-    // END TRANSITION CODE
-    else if (path === "/confirm") {
-      verifySecondaryAddress("verifyEmail");
-    }
-    else if (path === "/verify_email_address") {
-      verifySecondaryAddress("verifyUser");
-    }
-    else if (path === "/reset_password") {
-      verifySecondaryAddress("completePasswordReset");
-    }
-    else if (path === "/about") {
-      var module = bid.about.create();
-      module.start({});
-    }
-    else if (path === "/tos" || path === "/privacy") {
-      // do nothing.  This prevents "unknown path" from being displayed to the
-      // user.
-    }
-    else {
-      // Instead of throwing a hard error here, adding a message to the console
-      // to let developers know something is up.
-      helpers.log("unknown path");
-    }
-
     user.checkAuthentication(function(authenticated) {
+      if (!path || path === "/") {
+        bid.index();
+      }
+      else if (path === "/signin") {
+        if (authenticated) {
+          document.location = "/";
+          return;
+        }
+        var module = bid.signIn.create();
+        module.start({});
+      }
+      else if (path === "/forgot") {
+        if (authenticated) {
+          document.location = "/";
+          return;
+        }
+        bid.forgot();
+      }
+      // START TRANSITION CODE
+      // add_email_address has been renamed to confirm. Once all outstanding
+      // emails are verified or expired, this can be removed. This change is
+      // scheduled to go into train-2012.07.20
+      else if (path === "/add_email_address") {
+        verifySecondaryAddress("verifyEmail");
+      }
+      // END TRANSITION CODE
+      else if (path === "/confirm") {
+        verifySecondaryAddress("verifyEmail");
+      }
+      else if (path === "/verify_email_address") {
+        verifySecondaryAddress("verifyUser");
+      }
+      else if (path === "/reset_password") {
+        verifySecondaryAddress("completePasswordReset");
+      }
+      else if (path === "/about") {
+        var module = bid.about.create();
+        module.start({});
+      }
+      else if (path === "/tos" || path === "/privacy") {
+        // do nothing.  This prevents "unknown path" from being displayed to the
+        // user.
+      }
+      else {
+        // Instead of throwing a hard error here, adding a message to the console
+        // to let developers know something is up.
+        helpers.log("unknown path");
+      }
+
       if (authenticated) {
         displayAuthenticated();
       }
-- 
GitLab