Antoine Duparay - antoine.duparay@mozfr.org
Un objet, trois fonctions
navigator.id.request()
navigator.id.watch()
navigator.id.logout()
<script src="https://login.persona.org/include.js"></script>
<button onclick="navigator.id.request()">Login</button>
navigator.id.watch({
loggedInUser: currentUser,
onlogin: function(assertion) {
// A user has logged in! Here you need to:
// 1. Send the assertion to your backend for verification and to create a session.
// 2. Update your UI.
$.ajax({
type: 'POST',
url: '/auth/login', // This is a URL on your website.
data: {assertion: assertion},
success: function(res, status, xhr) { window.location.reload(); },
error: function(xhr, status, err) { alert("Login failure: " + err); }
});
},
onlogout: function() {}});
{ "status":"okay", "email":"bob@foobar.fr", "audience":"https://a.com:443",
"expires":1308859352261, "issuer":"eyedee.me"}