discourse/app/views/common/_persona_javascript.html.erb
2013-05-31 13:16:14 -04:00

30 lines
753 B
Plaintext

<!-- 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>