$(document).ready( function () {
$('#<%= $signinId %>').bind( 'click', function (e) {
e.preventDefault();
navigator.id.request({
siteName: "<%= $siteName %>",
siteLogo: "<%= $siteLogo %>",
privacyPolicy: "<%= $privacyPolicy %>",
termsOfService: "<%= $termsOfService %>",
});
});
$('#<%= $signoutId %>').bind( 'click', function (e) {
e.preventDefault();
navigator.id.logout();
});
});
navigator.id.watch({
loggedInUser: personaCurrentUser,
onlogin: function(assertion) {
$.ajax({
type: 'POST',
url: '<%= $signinPath %>',
data: {assertion: assertion},
success: function(res, status, xhr) {
if ( res.signin == false ) {
alert("Unknown error while verifying your authentication!");
}
else if ( res.signin == true && res.result.status == "failure" ) {
alert("Verifiction of your authentication failed: \n" + res.result.reason);
}
else {
window.location.reload();
}
},
error: function(xhr, status, err) {
alert('Network error: ' + err);
}
});
},
onlogout: function() {
$.ajax({
type: 'POST',
url: '<%= $signoutPath %>',
success: function(res, status, xhr) { window.location.reload(); },
error: function(xhr, status, err) {
alert('Network error: ' + err);
}
});
}
});