Beneath are basic questions which will be asked by a developer wanting to use BrowserID. They are arranged in order of importance. For each question there are two answers which represent the two competing API proposals (nicknamed the garfield and odie proposals).
You need to add a button to your site that, once clicked, will make a javascript call to prompt the user for and identity. You need to call a function at the time your site loads to check to see if a user is already (persistently logged in). Finally, these client side functions provide you with an assertions that you must implement a little bit of server logic to verify.
navigator.id.getVerifiedEmail({ immediate: false }, function(assertion) {
// assertion is undefined on failure, else success.
});
navigator.id.promptUser(function(assertion) {
// assertion is undefined on failure, else success.
});
In both APIs you must add a function call to your page at page load time to check if the user is already signed in.
navigator.id.getVerifiedEmail({ immediate: true }, function(assertion) {
// assertion is undefined on failure, else success.
});
navigator.id.getCurrent(function(assertion) {
// assertion is undefined on failure, else success.
});
Yes! You have to tell BrowserID that the user is logging out in order to clear their 'keep me signed in' preference.
navigator.id.setVerifiedEmailOptions({ persistent: false }, function() {
// at the time this function is called, the change has been made
});
navigator.id.logout(function() {
// at the time this function is called, the user has been logged out.
});
When you call getVerifiedEmail
, you should add a requiredEmail
property to the options block.
This is true both with the immediate flag true at page load, and with the immediate flag false at sign in click time.
Two things:
-
When you call
promptUser()
you should add arequiredEmail
property to the options block. -
When you call
getCurrent()
you should add a check to see if the assertion available is associated with the email address you require:if (assertion && assertion.email === email_i_Want) // accept assertion