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