2013-04-18 04:04:52 -04:00
|
|
|
<!-- TODO, move this into login UI, don't deliver with page -->
|
2013-03-01 10:23:21 -05:00
|
|
|
<script>
|
2013-04-18 04:04:52 -04:00
|
|
|
$LAB.script("https://login.persona.org/include.js").wait(function(){
|
2013-03-01 10:23:21 -05:00
|
|
|
(function() {
|
|
|
|
var readyCalled = false;
|
|
|
|
navigator.id.watch({
|
|
|
|
onlogin: function(assertion) {
|
|
|
|
if (readyCalled) {
|
2013-05-07 13:30:12 -04:00
|
|
|
Discourse.ajax('/auth/persona/callback', {
|
2013-03-01 14:22:54 -05:00
|
|
|
type: 'POST',
|
|
|
|
data: { 'assertion': assertion },
|
|
|
|
dataType: 'json'
|
2013-05-31 13:16:14 -04:00
|
|
|
}).then(function(data) {
|
|
|
|
Discourse.authenticationComplete(data);
|
2013-03-01 14:22:54 -05:00
|
|
|
});
|
2013-03-01 10:23:21 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
onlogout: function() {
|
|
|
|
if (readyCalled) {
|
|
|
|
Discourse.logout();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onready: function() {
|
|
|
|
readyCalled = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}());
|
2013-04-18 04:04:52 -04:00
|
|
|
});
|
2013-03-01 10:23:21 -05:00
|
|
|
</script>
|