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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc

Issue 1463753002: ChromeOS: This CL fixes bug in UserManager::GetKnownUserAccountId . (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
6 6
7 #include "ash/system/chromeos/devicetype_utils.h" 7 #include "ash/system/chromeos/devicetype_utils.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 NetworkError::ERROR_REASON_FRAME_ERROR; 442 NetworkError::ERROR_REASON_FRAME_ERROR;
443 frame_state_ = FRAME_STATE_ERROR; 443 frame_state_ = FRAME_STATE_ERROR;
444 UpdateState(error_reason); 444 UpdateState(error_reason);
445 } 445 }
446 446
447 AccountId GaiaScreenHandler::GetAccountId( 447 AccountId GaiaScreenHandler::GetAccountId(
448 const std::string& authenticated_email, 448 const std::string& authenticated_email,
449 const std::string& gaia_id) const { 449 const std::string& gaia_id) const {
450 const std::string canonicalized_email = 450 const std::string canonicalized_email =
451 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email)); 451 gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email));
452 const AccountId authenticated_account_id(
453 AccountId::FromUserEmailGaiaId(canonicalized_email, gaia_id));
454 452
455 // If we don't have UserManager instance (i.e. we are in unit test), 453 const AccountId account_id = user_manager::UserManager::GetKnownUserAccountId(
456 // or a known user has authenticated, just log in. 454 authenticated_email, gaia_id);
457 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
458 if (!user_manager || user_manager->IsKnownUser(authenticated_account_id))
459 return authenticated_account_id;
460 455
461 // If [part of] user id has changed, update stored data and connect user 456 if (account_id.GetUserEmail() != canonicalized_email) {
462 // to existing home directory. 457 LOG(WARNING) << "Existing user '" << account_id.GetUserEmail()
463 AccountId old_account_id(EmptyAccountId()); 458 << "' authenticated by alias '" << canonicalized_email << "'.";
464 if (!user_manager->GetKnownUserAccountId(authenticated_account_id,
465 &old_account_id)) {
466 return authenticated_account_id;
467 } 459 }
468 460
469 if (old_account_id.GetUserEmail() != canonicalized_email) { 461 return account_id;
470 LOG(WARNING) << "Existing user '" << old_account_id.GetUserEmail()
471 << "' authenticated by alias '" << canonicalized_email << "'.";
472 return old_account_id;
473 }
474
475 return authenticated_account_id;
476 } 462 }
477 463
478 void GaiaScreenHandler::HandleCompleteAuthentication( 464 void GaiaScreenHandler::HandleCompleteAuthentication(
479 const std::string& gaia_id, 465 const std::string& gaia_id,
480 const std::string& email, 466 const std::string& email,
481 const std::string& password, 467 const std::string& password,
482 const std::string& auth_code, 468 const std::string& auth_code,
483 bool using_saml, 469 bool using_saml,
484 const std::string& gaps_cookie) { 470 const std::string& gaps_cookie) {
485 if (!Delegate()) 471 if (!Delegate())
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 bool GaiaScreenHandler::IsRestrictiveProxy() const { 877 bool GaiaScreenHandler::IsRestrictiveProxy() const {
892 return !disable_restrictive_proxy_check_for_test_ && 878 return !disable_restrictive_proxy_check_for_test_ &&
893 !IsOnline(captive_portal_status_); 879 !IsOnline(captive_portal_status_);
894 } 880 }
895 881
896 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { 882 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() {
897 disable_restrictive_proxy_check_for_test_ = true; 883 disable_restrictive_proxy_check_for_test_ = true;
898 } 884 }
899 885
900 } // namespace chromeos 886 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screens/user_selection_screen.cc ('k') | components/user_manager/user_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698