Created
September 3, 2013 21:31
-
-
Save callahad/6429881 to your computer and use it in GitHub Desktop.
Disable Persona session hints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 21d898eb00cbcb1ffcab7d5e0ec01a4e80499ea5 Mon Sep 17 00:00:00 2001 | |
From: Dan Callahan <[email protected]> | |
Date: Tue, 3 Sep 2013 16:30:44 -0500 | |
Subject: [PATCH] Hack to ignore Persona session hints | |
--- | |
mediagoblin/plugins/persona/static/js/persona.js | 18 +++++++++++++++++- | |
1 files changed, 17 insertions(+), 1 deletions(-) | |
diff --git a/mediagoblin/plugins/persona/static/js/persona.js b/mediagoblin/plugins/persona/static/js/persona.js | |
index 47006e3..0dfcb91 100644 | |
--- a/mediagoblin/plugins/persona/static/js/persona.js | |
+++ b/mediagoblin/plugins/persona/static/js/persona.js | |
@@ -40,12 +40,28 @@ $(document).ready(function () { | |
var logout_url = document.getElementById('_logout_url').value; | |
+ // Temporary hack to ignore automatic callback invocations | |
+ // | |
+ // Persona automatically invokes either onlogin or onlogout when the page | |
+ // loads, to hint at the user's desired state. It then invokes onready to | |
+ // signal that it's finished running any automatic callbacks. | |
+ // | |
+ // We want to ignore the automatic callbacks to prevent an infinite loop, | |
+ // and force Persona to behave without session management hints. Thus, we | |
+ // neutralize the onlogin and onlogout callbacks until after onready fires. | |
+ var ready = false; | |
+ | |
navigator.id.watch({ | |
+ onready: function() { ready = true; }, | |
onlogin: function(assertion) { | |
+ if (!ready) { return; } // Hack | |
+ | |
document.getElementById('_assertion').value = assertion; | |
- document.getElementById('_persona_login').submit() | |
+ document.getElementById('_persona_login').submit(); | |
}, | |
onlogout: function() { | |
+ if (!ready) { return; } // Hack | |
+ | |
$.ajax({ | |
type: 'GET', | |
url: logout_url, | |
-- | |
1.7.7.5 (Apple Git-26) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment