Index: remoting/webapp/crd/js/host_controller.js |
diff --git a/remoting/webapp/crd/js/host_controller.js b/remoting/webapp/crd/js/host_controller.js |
index b8015721ee913f309cb5b1e1e262af9e75e518f6..7be18f7065f930fb645aded1179a7f19bf96a15f 100644 |
--- a/remoting/webapp/crd/js/host_controller.js |
+++ b/remoting/webapp/crd/js/host_controller.js |
@@ -172,8 +172,8 @@ remoting.HostController.prototype.start = function(hostPin, consent) { |
// Register the host and extract an optional auth code from the host |
// response. The absence of an auth code is represented by an empty |
// string. |
Jamie
2015/04/27 23:24:24
Is this comment still correct?
John Williams
2015/04/28 20:27:40
Fixed.
|
- /** @type {!Promise<string>} */ |
- var authCodePromise = Promise.all([ |
+ /** @type {!Promise<remoting.HostListApi.RegisterResult>} */ |
+ var regResultPromise = Promise.all([ |
hostClientIdPromise, |
hostNamePromise, |
keyPairPromise |
@@ -184,16 +184,26 @@ remoting.HostController.prototype.start = function(hostPin, consent) { |
return remoting.HostListApi.getInstance().register( |
newHostId, hostName, keyPair.publicKey, hostClientId); |
- }).then(function(/** string */ result) { |
+ }).then(function(/** remoting.HostListApi.RegisterResult */ result) { |
hostRegistered = true; |
return result; |
}); |
// Get XMPP creditials. |
- var xmppCredsPromise = authCodePromise.then(function(authCode) { |
- if (authCode) { |
+ var xmppCredsPromise = regResultPromise.then(function(regResult) { |
+ if (regResult.authCode && regResult.email) { |
+ // Use auth code and email supplied by GCD. |
+ return that.hostDaemonFacade_.getRefreshTokenFromAuthCode( |
+ regResult.authCode).then(function(token) { |
+ return { |
+ userEmail: regResult.email, |
+ refreshToken: token |
+ }; |
+ }); |
+ } else if (regResult.authCode) { |
// Use auth code supplied by Chromoting registry. |
- return that.hostDaemonFacade_.getCredentialsFromAuthCode(authCode); |
+ return that.hostDaemonFacade_.getCredentialsFromAuthCode( |
+ regResult.authCode); |
} else { |
// No authorization code returned, use regular Chrome |
// identity credential flow. |
@@ -207,8 +217,8 @@ remoting.HostController.prototype.start = function(hostPin, consent) { |
}); |
// Get as JID to use as the host owner. |
- var hostOwnerPromise = authCodePromise.then(function(authCode) { |
- if (authCode) { |
+ var hostOwnerPromise = regResultPromise.then(function(regResult) { |
+ if (regResult.authCode && !regResult.email) { |
Jamie
2015/04/27 23:24:24
This doesn't look right. You're never using regRes
John Williams
2015/04/28 20:27:40
Done.
|
return that.getClientBaseJid_(); |
} else { |
return remoting.identity.getEmail(); |