diff options
author | robliao@chromium.org <robliao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 21:41:05 +0000 |
---|---|---|
committer | robliao@chromium.org <robliao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 21:41:05 +0000 |
commit | 6b4c88b9d8dc0dbcca025bd768dd62dce09d362a (patch) | |
tree | 68d5146218381623e8f71c6c0a5798ea016946ea | |
parent | cb13d46c21410058b570310093b4ea071a67fe17 (diff) | |
download | chromium_src-6b4c88b9d8dc0dbcca025bd768dd62dce09d362a.zip chromium_src-6b4c88b9d8dc0dbcca025bd768dd62dce09d362a.tar.gz chromium_src-6b4c88b9d8dc0dbcca025bd768dd62dce09d362a.tar.bz2 |
Fix Invalidating Authentication Tokens on Failure
BUG=352731
R=vadimt@chromium.org
Review URL: https://codereview.chromium.org/200673002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257215 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/google_now/background.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/chrome/browser/resources/google_now/background.js b/chrome/browser/resources/google_now/background.js index a3b49b2..f7f48a0 100644 --- a/chrome/browser/resources/google_now/background.js +++ b/chrome/browser/resources/google_now/background.js @@ -250,13 +250,17 @@ function recordEvent(event) { /** * Checks the result of the HTTP Request and updates the authentication * manager on any failure. - * @param {XMLHttpRequest} request XMLHttpRequest that sent the authenticated - * request. + * @param {string} token Authentication token to validate against an + * XMLHttpRequest. + * @return {function(XMLHttpRequest)} Function that validates the token with the + * supplied XMLHttpRequest. */ -function checkAuthenticationStatus(request) { - if (request.status == HTTP_FORBIDDEN || - request.status == HTTP_UNAUTHORIZED) { - authenticationManager.removeToken(token); +function checkAuthenticationStatus(token) { + return function(request) { + if (request.status == HTTP_FORBIDDEN || + request.status == HTTP_UNAUTHORIZED) { + authenticationManager.removeToken(token); + } } } @@ -278,7 +282,7 @@ function requestFromServer(method, handlerName, opt_contentType) { }, false); request.send(); }); - requestPromise.then(checkAuthenticationStatus); + requestPromise.then(checkAuthenticationStatus(token)); return requestPromise; }); } |