Skip to content
Snippets Groups Projects
Commit 32d4f41e authored by Shane Tomlinson's avatar Shane Tomlinson
Browse files

Generalize the logic for checking the redirect if authenticated paths.

parent 6f1f962d
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ $(function() {
xhr = bid.XHR,
network = bid.Network,
token = pageHelpers.getParameterByName("token"),
path = document.location.pathname,
path = document.location.pathname || "/",
moduleManager = bid.module,
modules = bid.Modules,
CookieCheck = modules.CookieCheck,
......@@ -26,7 +26,8 @@ $(function() {
XHRDisableForm = modules.XHRDisableForm,
Development = modules.Development,
ANIMATION_TIME = 500,
checkCookiePaths = [ "/signin", "/signup", "/forgot", "/add_email_address", "/confirm", "/verify_email_address" ];
checkCookiePaths = [ "/signin", "/forgot", "/add_email_address", "/confirm", "/verify_email_address" ],
redirectIfAuthenticatedPaths = [ "/signin", "/forgot" ];
function shouldCheckCookies(path) {
......@@ -38,6 +39,7 @@ $(function() {
}
}
// Firefox and IE have rendering bugs where if the box-sizing is set to
// border-box and a min-height is set, padding is added on top of the
// min-height, making elements render using the normal W3C box model. Use
......@@ -131,23 +133,23 @@ $(function() {
if (!status) return;
user.checkAuthentication(function(authenticated) {
if (!path || path === "/") {
// If the user is authenticated and the path should not be allowed if the
// user is authenticated, redirect them back to the main page. See issue
// #1345 https://github.com/mozilla/browserid/issues/1345
if (authenticated && _.indexOf(redirectIfAuthenticatedPaths, path) > -1) {
document.location = "/";
return;
}
else if (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();
var module = bid.forgot.create();
module.start({});
}
// START TRANSITION CODE
// add_email_address has been renamed to confirm. Once all outstanding
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment