To start a service discovery call to LoginController.startDiscovery() method must be made:
cwic.LoginController.startDiscovery();
But before service discovery starts following event handlers must be set:
- Event handler for "onEmailRequired" event
- Event handler for "onCredentialsRequired" event
function onEmailRequired()
{
var email;
//...
// Prompt user for email here...
//...
cwic.LoginController.setEmail(email);
}
function onCredentialsRequired()
{
var username;
var password
// ...
// Prompt user for credentials here...
// ...
cwic.LoginController.setCredentials(username, password);
}
cwic.LoginController.addEventHandler("onEmailRequired", onEmailRequired);
cwic.LoginController.addEventHandler("onCredentialsRequired", onCredentialsRequired);
cwic.LoginController.startDiscovery();
Once service discovery, "onEmailRequired" starts event will be
fired. If email address is valid, "onCredentialsRequired"
event will be fired. If user's credentials are valid, user will be signed in.