Skip to content

Instantly share code, notes, and snippets.

@seanmonstar
Created August 21, 2013 19:05
Show Gist options
  • Save seanmonstar/6298777 to your computer and use it in GitHub Desktop.
Save seanmonstar/6298777 to your computer and use it in GitHub Desktop.
<script src="https://login.persona.org/include.js"></script>
navigator.id.watch({
onlogin: function(assertion) {
$.post('/user/login', { assertion: assertion}).done(loggedIn);
},
onlogout: function() {
$.post('/user/logout').done(loggedOut);
}
});
$('#login').click(function() {
navigator.id.request();
});
app.post('/user/login', function(req, res) {
request.post('https://verifier.login.persona.org/verify', { json: {
assertion: req.body.assertion, audience: 'example.com'
}}, function(err, r, body) {
if (body.status === 'okay') {
res.json({ email: body.email });
} else {
res.send(401, 'Unauthorized');
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment