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

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: Address reviewer's feedback 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
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..a49bfa58d54bd5aaf01d727611b08b9541bf4830 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,18 @@ remoting.initIdentity = function(onUserInfoAvailable) {
}
if (base.isAppsV2()) {
- remoting.identity = new remoting.Identity(promptForConsent);
+ remoting.identity = new remoting.Identity();
} else {
// TODO(garykac) Remove this and replace with identity.
remoting.oauth2 = new remoting.OAuth2();
- if (!remoting.oauth2.isAuthenticated()) {
- document.getElementById('auth-dialog').hidden = false;
- }
remoting.identity = remoting.oauth2;
+ if (!remoting.identity.isAuthenticated()) {
+ remoting.AuthDialog.show().then(function() {
+ remoting.identity.handleAuthFailureAndRelaunch();
+ });
+ }
}
remoting.identity.getUserInfo(onUserInfoAvailable,
onGetIdentityInfoError);
-}
+};

Powered by Google App Engine
This is Rietveld 408576698