defer persona init till after people launch the login dialog

This commit is contained in:
Sam
2013-08-26 17:51:41 +10:00
parent d0b4c751b7
commit ac905d4a08
3 changed files with 31 additions and 30 deletions
@@ -1,29 +0,0 @@
<!-- TODO, move this into login UI, don't deliver with page -->
<script>
$LAB.script("https://login.persona.org/include.js").wait(function(){
(function() {
var readyCalled = false;
navigator.id.watch({
onlogin: function(assertion) {
if (readyCalled) {
Discourse.ajax('/auth/persona/callback', {
type: 'POST',
data: { 'assertion': assertion },
dataType: 'json'
}).then(function(data) {
Discourse.authenticationComplete(data);
});
}
},
onlogout: function() {
if (readyCalled) {
Discourse.logout();
}
},
onready: function() {
readyCalled = true;
}
});
}());
});
</script>