From cbf2e7d9d9da00914b6e98cf6eeb6a1541e90ca5 Mon Sep 17 00:00:00 2001 From: Ben Adida <ben@adida.net> Date: Fri, 6 Jul 2012 14:50:57 -0700 Subject: [PATCH] special case auth_with_primary so that we have context and we redirect appropriately --- resources/static/auth_with_idp/main.js | 8 +++++++- resources/static/authentication_api.js | 10 ++++++++-- resources/static/pages/js/page_helpers.js | 7 +------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/resources/static/auth_with_idp/main.js b/resources/static/auth_with_idp/main.js index d0ee9697a..0e759ca49 100644 --- a/resources/static/auth_with_idp/main.js +++ b/resources/static/auth_with_idp/main.js @@ -5,7 +5,13 @@ var wc = WinChan.onOpen(function(origin, args, cb) { if (window.location.hash === '#complete') cb(); else { + var fullURL = args; + + // store information in window.name to indicate that + // we redirect here + window.name = 'auth_with_primary'; + wc.detach(); - window.location = args; + window.location = fullURL; } }); diff --git a/resources/static/authentication_api.js b/resources/static/authentication_api.js index ca9b16c49..8e2a0e98b 100644 --- a/resources/static/authentication_api.js +++ b/resources/static/authentication_api.js @@ -33,11 +33,17 @@ }; navigator.id.completeAuthentication = function(cb) { - window.location = 'https://login.persona.org/sign_in#AUTH_RETURN'; + if (window.name == 'auth_with_primary') + window.location = 'https://login.persona.org/authenticate_with_primary#complete'; + else + window.location = 'https://login.persona.org/sign_in#AUTH_RETURN'; }; navigator.id.raiseAuthenticationFailure = function(reason) { - window.location = 'https://login.persona.org/sign_in#AUTH_RETURN_CANCEL'; + if (window.name == 'auth_with_primary') + window.location = 'https://login.persona.org/authenticate_with_primary#complete'; + else + window.location = 'https://login.persona.org/sign_in#AUTH_RETURN_CANCEL'; }; navigator.id._primaryAPIIsShimmed = true; diff --git a/resources/static/pages/js/page_helpers.js b/resources/static/pages/js/page_helpers.js index 47389799d..758f4df8e 100644 --- a/resources/static/pages/js/page_helpers.js +++ b/resources/static/pages/js/page_helpers.js @@ -136,17 +136,12 @@ BrowserID.PageHelpers = (function() { throw "cannot verify with primary without an email address and URL" } - var url = helpers.toURL(baseURL, { - email: email, - return_to: "https://login.persona.org/authenticate_with_primary#complete" - }); - winchan.open({ url: "https://login.persona.org/authenticate_with_primary", // This is the relay that will be used when the IdP redirects to sign_in_complete relay_url: "https://login.persona.org/relay", window_features: "width=700,height=375", - params: url + params: helpers.toURL(baseURL, {email: email}) }, function(error, result) { // We have to force a reset of the primary caches because the user's // authentication status may be incorrect. -- GitLab