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

Unified Diff: remoting/webapp/base/js/auth_init.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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/base/js/auth_dialog.js ('k') | remoting/webapp/crd/js/activation_handler.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/auth_init.js
diff --git a/remoting/webapp/base/js/auth_init.js b/remoting/webapp/base/js/auth_init.js
index 2602efc8112998bda10b4c8b85bc85fb9e822707..8312c31077fa08056665fefa3fe578a08d562f02 100644
--- a/remoting/webapp/base/js/auth_init.js
+++ b/remoting/webapp/base/js/auth_init.js
@@ -16,34 +16,6 @@ var remoting = remoting || {};
*/
remoting.initIdentity = function(onUserInfoAvailable) {
- /**
- * Show the authorization consent UI and register a one-shot event handler to
- * continue the authorization process.
- *
- * @param {function():void} authContinue Callback to invoke when the user
- * clicks "Continue".
- */
- function promptForConsent(authContinue) {
- /** @type {HTMLElement} */
- var dialog = document.getElementById('auth-dialog');
- /** @type {HTMLElement} */
- var button = document.getElementById('auth-button');
- var consentGranted = function(event) {
- dialog.hidden = true;
- button.removeEventListener('click', consentGranted, false);
- authContinue();
- remoting.windowShape.updateClientWindowShape();
- };
- dialog.hidden = false;
-
- /** @type {HTMLElement} */
- var dialog_border = document.getElementById('auth-dialog-border');
- remoting.authDialog = new remoting.AuthDialog(dialog_border);
- remoting.windowShape.addCallback(remoting.authDialog);
-
- button.addEventListener('click', consentGranted, false);
- }
-
/** @param {remoting.Error} error */
function onGetIdentityInfoError(error) {
// No need to show the error message for NOT_AUTHENTICATED
@@ -54,16 +26,38 @@ remoting.initIdentity = function(onUserInfoAvailable) {
}
if (base.isAppsV2()) {
- remoting.identity = new remoting.Identity(promptForConsent);
+ remoting.identity =
+ new remoting.Identity(remoting.AuthDialog.getInstance());
} else {
// TODO(garykac) Remove this and replace with identity.
remoting.oauth2 = new remoting.OAuth2();
- if (!remoting.oauth2.isAuthenticated()) {
- document.getElementById('auth-dialog').hidden = false;
+ var oauth2 = /** @type {*} */ (remoting.oauth2);
+ remoting.identity = /** @type {remoting.Identity} */ (oauth2);
+ if (!remoting.identity.isAuthenticated()) {
+ remoting.AuthDialog.getInstance().show().then(function() {
+ remoting.oauth2.doAuthRedirect(function(){
+ window.location.reload();
+ });
+ });
}
- remoting.identity = remoting.oauth2;
}
remoting.identity.getUserInfo(onUserInfoAvailable,
onGetIdentityInfoError);
-}
+};
+
+/**
+ * Removes the cached token and restarts the app.
+ *
+ * @return {void} Nothing.
+ */
+remoting.handleAuthFailureAndRelaunch = function() {
+ remoting.identity.removeCachedAuthToken(function(){
+ if (base.isAppsV2()) {
+ base.Ipc.invoke('remoting.ActivationHandler.restart',
+ chrome.app.window.current().id);
+ } else {
+ window.location.reload();
+ }
+ });
+};
« no previous file with comments | « remoting/webapp/base/js/auth_dialog.js ('k') | remoting/webapp/crd/js/activation_handler.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698