Bug 1022193 - Add a "forceIdSelection" to navigator.getMobileIdAssertion. Part 3: MobileIdentityManager. r=jedp

This commit is contained in:
Fernando Jiménez 2014-06-27 01:18:21 +02:00
parent 124deb464a
commit 837bd9f64b

View File

@ -88,8 +88,7 @@ let MobileIdentityManager = {
let promiseId = msg.promiseId;
this.messageManagers[promiseId] = aMessage.target;
this.getMobileIdAssertion(aMessage.principal, promiseId,
msg.msisdn, msg.prompt);
this.getMobileIdAssertion(aMessage.principal, promiseId, msg.options);
},
observe: function(subject, topic, data) {
@ -701,7 +700,7 @@ let MobileIdentityManager = {
return deferred.promise;
},
getMobileIdAssertion: function(aPrincipal, aPromiseId) {
getMobileIdAssertion: function(aPrincipal, aPromiseId, aOptions) {
log.debug("getMobileIdAssertion ${}", aPrincipal);
let uri = Services.io.newURI(aPrincipal.origin, null, null);
@ -716,12 +715,18 @@ let MobileIdentityManager = {
.then(
(creds) => {
log.debug("creds ${creds} - ${origin}", { creds: creds,
origin: aPrincipal.origin});
origin: aPrincipal.origin });
if (!creds || !creds.sessionToken) {
log.debug("No credentials");
return;
}
// Even if we already have credentials for this origin, the consumer of
// the API might want to force the identity selection dialog.
if (aOptions.forceSelection) {
return this.promptAndVerify(principal, manifestURL, creds);
}
// It is possible that the ICC associated with the stored
// credentials is not present in the device anymore, so we ask the
// user if she still wants to use it anyway or if she prefers to use
@ -739,6 +744,7 @@ let MobileIdentityManager = {
// what to do.
return this.promptAndVerify(principal, manifestURL, creds);
}
return creds;
}
)