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-03-01 14:22:54 -05:00
|
|
|
|
2013-04-01 16:28:26 -04:00
|
|
|
Discourse.ajax({
|
2013-03-01 14:22:54 -05:00
|
|
|
type: 'POST',
|
2013-03-14 08:01:52 -04:00
|
|
|
url: Discourse.getURL('/auth/persona/callback'),
|
2013-03-01 14:22:54 -05:00
|
|
|
data: { 'assertion': assertion },
|
|
|
|
success: function(data, textStatus, jqXHR) {
|
|
|
|
Discourse.authenticationComplete(data);
|
|
|
|
},
|
|
|
|
dataType: 'json'
|
|
|
|
});
|
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>
|