Chromium Code Reviews| Index: chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc |
| diff --git a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc |
| index 34c61120f6cc61fb28641bd50aa29d52c23725ff..6eda49e630cf2d46c4fb82191c8c7eaa1b716097 100644 |
| --- a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc |
| +++ b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc |
| @@ -515,6 +515,28 @@ void GaiaScreenHandler::HandleWebviewLoadAborted( |
| UpdateState(error_reason); |
| } |
| +std::string GaiaScreenHandler::GetCanonicalEmail( |
| + const std::string& authenticated_email, |
| + const std::string& gaia_id) const { |
| + const std::string sanitized_email = gaia::SanitizeEmail(authenticated_email); |
| + |
| + const std::string canonicalized_email = |
| + gaia::CanonicalizeEmail(sanitized_email); |
| + user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| + if (user_manager && !user_manager->IsKnownUser(canonicalized_email)) { |
| + std::string old_email; |
| + if (user_manager->GetKnownUserCanonicalEmail(gaia_id, &old_email)) { |
| + if (old_email != canonicalized_email) { |
| + 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.
|
| + << "' authenticated by alias '" << canonicalized_email |
| + << "'."; |
| + return old_email; |
| + } |
| + } |
| + } |
| + 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
|
| +} |
| + |
| void GaiaScreenHandler::HandleCompleteAuthentication( |
| const std::string& gaia_id, |
| const std::string& email, |
| @@ -531,7 +553,9 @@ void GaiaScreenHandler::HandleCompleteAuthentication( |
| DCHECK(!gaia_id.empty()); |
| const std::string sanitized_email = gaia::SanitizeEmail(email); |
| Delegate()->SetDisplayEmail(sanitized_email); |
| - UserContext user_context(sanitized_email); |
| + |
| + const std::string canonical_email = GetCanonicalEmail(email, gaia_id); |
| + UserContext user_context(canonical_email); |
| user_context.SetGaiaID(gaia_id); |
| user_context.SetKey(Key(password)); |
| user_context.SetAuthCode(auth_code); |
| @@ -657,7 +681,8 @@ void GaiaScreenHandler::DoCompleteLogin(const std::string& gaia_id, |
| DCHECK(!gaia_id.empty()); |
| const std::string sanitized_email = gaia::SanitizeEmail(typed_email); |
| Delegate()->SetDisplayEmail(sanitized_email); |
| - UserContext user_context(sanitized_email); |
| + const std::string canonical_email = GetCanonicalEmail(typed_email, gaia_id); |
| + UserContext user_context(canonical_email); |
| user_context.SetGaiaID(gaia_id); |
| user_context.SetKey(Key(password)); |
| user_context.SetAuthFlow(using_saml |