Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: remoting/webapp/crd/js/oauth2.js

Issue 868203002: Handle authentication failures in the v2 app by restarting the app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/webapp/crd/js/it2me_helpee_channel.js ('k') | remoting/webapp/crd/js/remoting.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * OAuth2 class that handles retrieval/storage of an OAuth2 token. 7 * OAuth2 class that handles retrieval/storage of an OAuth2 token.
8 * 8 *
9 * Uses a content script to trampoline the OAuth redirect page back into the 9 * Uses a content script to trampoline the OAuth redirect page back into the
10 * extension context. This works around the lack of native support for 10 * extension context. This works around the lack of native support for
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 /** @return {boolean} True if the app is already authenticated. */ 76 /** @return {boolean} True if the app is already authenticated. */
77 remoting.OAuth2.prototype.isAuthenticated = function() { 77 remoting.OAuth2.prototype.isAuthenticated = function() {
78 if (this.getRefreshToken()) { 78 if (this.getRefreshToken()) {
79 return true; 79 return true;
80 } 80 }
81 return false; 81 return false;
82 }; 82 };
83 83
84 /** 84 /**
85 * Removes all storage, and effectively unauthenticates the user. 85 * Remove the cached auth token, if any.
86 * 86 *
87 * @param {function():void=} opt_onDone Completion callback.
87 * @return {void} Nothing. 88 * @return {void} Nothing.
88 */ 89 */
89 remoting.OAuth2.prototype.clear = function() { 90 remoting.OAuth2.prototype.removeCachedAuthToken = function(opt_onDone) {
90 window.localStorage.removeItem(this.KEY_EMAIL_); 91 window.localStorage.removeItem(this.KEY_EMAIL_);
91 window.localStorage.removeItem(this.KEY_FULLNAME_); 92 window.localStorage.removeItem(this.KEY_FULLNAME_);
92 this.clearAccessToken_(); 93 this.clearAccessToken_();
93 this.clearRefreshToken_(); 94 this.clearRefreshToken_();
95 if (opt_onDone) {
96 opt_onDone();
97 }
94 }; 98 };
95 99
96 /** 100 /**
97 * Sets the refresh token. 101 * Sets the refresh token.
98 * 102 *
99 * @param {string} token The new refresh token. 103 * @param {string} token The new refresh token.
100 * @return {void} Nothing. 104 * @return {void} Nothing.
101 * @private 105 * @private
102 */ 106 */
103 remoting.OAuth2.prototype.setRefreshToken_ = function(token) { 107 remoting.OAuth2.prototype.setRefreshToken_ = function(token) {
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 * @return {?string} The user's full name, if it has been cached by a previous 461 * @return {?string} The user's full name, if it has been cached by a previous
458 * call to getUserInfo, otherwise null. 462 * call to getUserInfo, otherwise null.
459 */ 463 */
460 remoting.OAuth2.prototype.getCachedUserFullName = function() { 464 remoting.OAuth2.prototype.getCachedUserFullName = function() {
461 var value = window.localStorage.getItem(this.KEY_FULLNAME_); 465 var value = window.localStorage.getItem(this.KEY_FULLNAME_);
462 if (typeof value == 'string') { 466 if (typeof value == 'string') {
463 return value; 467 return value;
464 } 468 }
465 return null; 469 return null;
466 }; 470 };
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/it2me_helpee_channel.js ('k') | remoting/webapp/crd/js/remoting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698