discourse/app/views/common/_persona_javascript.html.erb
2013-04-01 18:09:23 -04:00

30 lines
748 B
Text

<script src="https://login.persona.org/include.js"></script>
<script>
(function() {
var readyCalled = false;
navigator.id.watch({
onlogin: function(assertion) {
if (readyCalled) {
Discourse.ajax({
type: 'POST',
url: Discourse.getURL('/auth/persona/callback'),
data: { 'assertion': assertion },
success: function(data, textStatus, jqXHR) {
Discourse.authenticationComplete(data);
},
dataType: 'json'
});
}
},
onlogout: function() {
if (readyCalled) {
Discourse.logout();
}
},
onready: function() {
readyCalled = true;
}
});
}());
</script>