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

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

Issue 1370913002: ChromeOS: fix user signin by alias. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixc HandleAuthentication. Created 5 years, 2 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
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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 else 508 else
509 frame_error_ = net::ERR_INTERNET_DISCONNECTED; 509 frame_error_ = net::ERR_INTERNET_DISCONNECTED;
510 510
511 LOG(ERROR) << "Gaia webview error: " << error_reason_str; 511 LOG(ERROR) << "Gaia webview error: " << error_reason_str;
512 NetworkError::ErrorReason error_reason = 512 NetworkError::ErrorReason error_reason =
513 NetworkError::ERROR_REASON_FRAME_ERROR; 513 NetworkError::ERROR_REASON_FRAME_ERROR;
514 frame_state_ = FRAME_STATE_ERROR; 514 frame_state_ = FRAME_STATE_ERROR;
515 UpdateState(error_reason); 515 UpdateState(error_reason);
516 } 516 }
517 517
518 std::string GaiaScreenHandler::GetCanonicalEmail(
519 const std::string& authenticated_email,
520 const std::string& gaia_id) const {
521 const std::string sanitized_email = gaia::SanitizeEmail(authenticated_email);
522
523 const std::string canonicalized_email =
524 gaia::CanonicalizeEmail(sanitized_email);
525 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
526 if (user_manager && !user_manager->IsKnownUser(canonicalized_email)) {
527 std::string old_email;
528 if (user_manager->GetKnownUserCanonicalEmail(gaia_id, &old_email)) {
529 if (old_email != canonicalized_email) {
530 LOG(WARNING) << "Existing user '" << old_email
achuithb 2015/09/29 18:18:42 Should we make this LOG(INFO)? Also, should we ad
Alexander Alekseev 2015/09/29 19:02:07 LOG(INFO) is prohibited by precommit hooks. So you
achuithb 2015/09/29 19:07:48 Doesn't feel like a WARNING, but I guess it's ok.
531 << "' authenticated by alias '" << canonicalized_email
532 << "'.";
533 return old_email;
534 }
535 }
536 }
537 return sanitized_email;
achuithb 2015/09/29 18:18:42 The names are a bit confusing. This method is cal
Alexander Alekseev 2015/09/29 19:02:07 It actually is returning sanitized email for compa
538 }
539
518 void GaiaScreenHandler::HandleCompleteAuthentication( 540 void GaiaScreenHandler::HandleCompleteAuthentication(
519 const std::string& gaia_id, 541 const std::string& gaia_id,
520 const std::string& email, 542 const std::string& email,
521 const std::string& password, 543 const std::string& password,
522 const std::string& auth_code, 544 const std::string& auth_code,
523 bool using_saml, 545 bool using_saml,
524 const std::string& gaps_cookie) { 546 const std::string& gaps_cookie) {
525 if (!Delegate()) 547 if (!Delegate())
526 return; 548 return;
527 549
528 RecordGAIAFlowTypeHistogram(); 550 RecordGAIAFlowTypeHistogram();
529 551
530 DCHECK(!email.empty()); 552 DCHECK(!email.empty());
531 DCHECK(!gaia_id.empty()); 553 DCHECK(!gaia_id.empty());
532 const std::string sanitized_email = gaia::SanitizeEmail(email); 554 const std::string sanitized_email = gaia::SanitizeEmail(email);
533 Delegate()->SetDisplayEmail(sanitized_email); 555 Delegate()->SetDisplayEmail(sanitized_email);
534 UserContext user_context(sanitized_email); 556
557 const std::string canonical_email = GetCanonicalEmail(email, gaia_id);
558 UserContext user_context(canonical_email);
535 user_context.SetGaiaID(gaia_id); 559 user_context.SetGaiaID(gaia_id);
536 user_context.SetKey(Key(password)); 560 user_context.SetKey(Key(password));
537 user_context.SetAuthCode(auth_code); 561 user_context.SetAuthCode(auth_code);
538 user_context.SetAuthFlow(using_saml 562 user_context.SetAuthFlow(using_saml
539 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML 563 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML
540 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); 564 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML);
541 user_context.SetGAPSCookie(gaps_cookie); 565 user_context.SetGAPSCookie(gaps_cookie);
542 Delegate()->CompleteLogin(user_context); 566 Delegate()->CompleteLogin(user_context);
543 } 567 }
544 568
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 return; 674 return;
651 675
652 if (using_saml && !using_saml_api_) 676 if (using_saml && !using_saml_api_)
653 RecordSAMLScrapingVerificationResultInHistogram(true); 677 RecordSAMLScrapingVerificationResultInHistogram(true);
654 RecordGAIAFlowTypeHistogram(); 678 RecordGAIAFlowTypeHistogram();
655 679
656 DCHECK(!typed_email.empty()); 680 DCHECK(!typed_email.empty());
657 DCHECK(!gaia_id.empty()); 681 DCHECK(!gaia_id.empty());
658 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); 682 const std::string sanitized_email = gaia::SanitizeEmail(typed_email);
659 Delegate()->SetDisplayEmail(sanitized_email); 683 Delegate()->SetDisplayEmail(sanitized_email);
660 UserContext user_context(sanitized_email); 684 const std::string canonical_email = GetCanonicalEmail(typed_email, gaia_id);
685 UserContext user_context(canonical_email);
661 user_context.SetGaiaID(gaia_id); 686 user_context.SetGaiaID(gaia_id);
662 user_context.SetKey(Key(password)); 687 user_context.SetKey(Key(password));
663 user_context.SetAuthFlow(using_saml 688 user_context.SetAuthFlow(using_saml
664 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML 689 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML
665 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); 690 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML);
666 Delegate()->CompleteLogin(user_context); 691 Delegate()->CompleteLogin(user_context);
667 692
668 if (test_expects_complete_login_) { 693 if (test_expects_complete_login_) {
669 VLOG(2) << "Complete test login for " << typed_email 694 VLOG(2) << "Complete test login for " << typed_email
670 << ", requested=" << test_user_; 695 << ", requested=" << test_user_;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { 959 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() {
935 DCHECK(signin_screen_handler_); 960 DCHECK(signin_screen_handler_);
936 return signin_screen_handler_->delegate_; 961 return signin_screen_handler_->delegate_;
937 } 962 }
938 963
939 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { 964 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) {
940 signin_screen_handler_ = handler; 965 signin_screen_handler_ = handler;
941 } 966 }
942 967
943 } // namespace chromeos 968 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h ('k') | components/user_manager/user_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698