| Index: remoting/webapp/crd/js/oauth2.js
|
| diff --git a/remoting/webapp/crd/js/oauth2.js b/remoting/webapp/crd/js/oauth2.js
|
| index 52e12f8841480cf92bb92a8b2d7e274289e2e1cd..77d53234b93a63d980badeed28c17bf398ba2caf 100644
|
| --- a/remoting/webapp/crd/js/oauth2.js
|
| +++ b/remoting/webapp/crd/js/oauth2.js
|
| @@ -292,21 +292,35 @@ remoting.OAuth2.prototype.getAuthorizationCode = function(onDone) {
|
| /**
|
| * Redirect page to get a new OAuth Refresh Token.
|
| *
|
| - * @param {function():void} onDone Completion callback.
|
| - * @return {void} Nothing.
|
| + * @return {Promise} A promise that resolves when the token is received.
|
| */
|
| -remoting.OAuth2.prototype.doAuthRedirect = function(onDone) {
|
| +remoting.OAuth2.prototype.handleAuthFailure = function() {
|
| + var deferred = new base.Deferred();
|
| +
|
| /** @type {remoting.OAuth2} */
|
| var that = this;
|
| /** @param {?string} code */
|
| var onAuthorizationCode = function(code) {
|
| if (code) {
|
| - that.exchangeCodeForToken(code, onDone);
|
| + that.exchangeCodeForToken(code, deferred.resolve.bind(deferred));
|
| } else {
|
| - onDone();
|
| + deferred.reject(remoting.Error.NOT_AUTHENTICATED);
|
| }
|
| };
|
| this.getAuthorizationCode(onAuthorizationCode);
|
| +
|
| + return deferred.promise();
|
| +};
|
| +
|
| +/**
|
| + * Removes the cached token, prompts the user to get the new token and
|
| + * relaunches the current window.
|
| + * @return {void} Nothing.
|
| + */
|
| +remoting.OAuth2.prototype.handleAuthFailureAndRelaunch = function() {
|
| + this.handleAuthFailure().then(function() {
|
| + window.location.reload();
|
| + });
|
| };
|
|
|
| /**
|
|
|