2013-03-01 23:23:21 +08:00
|
|
|
<script src="https://login.persona.org/include.js"></script>
|
|
|
|
<script>
|
|
|
|
(function() {
|
|
|
|
var readyCalled = false;
|
|
|
|
navigator.id.watch({
|
|
|
|
onlogin: function(assertion) {
|
|
|
|
if (readyCalled) {
|
2013-03-02 03:22:54 +08:00
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: '/auth/persona/callback',
|
|
|
|
data: { 'assertion': assertion },
|
|
|
|
success: function(data, textStatus, jqXHR) {
|
|
|
|
Discourse.authenticationComplete(data);
|
|
|
|
},
|
|
|
|
dataType: 'json'
|
|
|
|
});
|
2013-03-01 23:23:21 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
onlogout: function() {
|
|
|
|
if (readyCalled) {
|
|
|
|
Discourse.logout();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onready: function() {
|
|
|
|
readyCalled = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}());
|
|
|
|
</script>
|