Skip to content

Instantly share code, notes, and snippets.

@naholyr
Created January 10, 2012 06:22
Show Gist options
  • Select an option

  • Save naholyr/1587384 to your computer and use it in GitHub Desktop.

Select an option

Save naholyr/1587384 to your computer and use it in GitHub Desktop.
[snippet] implement "remember me" with BrowserId
// https://github.com/mozilla/browserid/wiki/Advanced-BrowserID-Features
function login () {
function gotAssertion (assertion) {
if (assertion) {
// User chose not to log in, or an error occurred
} else {
// Ajax call to server to check email
}
}
// Retrieve previous session
navigator.id.get(function (assertion) {
if (assertion) {
// Got one!
gotAssertion(assertion);
} else {
// Need to log in for the first time
navigator.id.get(gotAssertion, {allowPersistent: true});
}
}, {silent: true});
}
function logout() {
navigator.id.logout(function (ok) {
// ok if the user is properly logged out
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment