Commit 71fd2e93 authored by Alexander Alekseev's avatar Alexander Alekseev Committed by Commit Bot

Chrome OS: Fix DCHECK in Offline Gaia screen.


Offline Gaia did not have dedicated API, so it crashed when trying to
sign-in as non-existing user. This CL adds a dedicated API which displays error
message to user.

Bug: 863847
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I8354a88befb7cb99a64519c3f3d07449ead8fc4d
Reviewed-on: https://chromium-review.googlesource.com/1141654
Commit-Queue: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarRoman Sorokin <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576256}
parent 910a4216
...@@ -1084,8 +1084,8 @@ login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { ...@@ -1084,8 +1084,8 @@ login.createScreen('GaiaSigninScreen', 'gaia-signin', function() {
} else if (credentials.useOffline) { } else if (credentials.useOffline) {
this.email = credentials.email; this.email = credentials.email;
chrome.send( chrome.send(
'authenticateUser', 'completeOfflineAuthentication',
[credentials.email, credentials.password, false]); [credentials.email, credentials.password]);
} else if (credentials.authCode) { } else if (credentials.authCode) {
chrome.send('completeAuthentication', [ chrome.send('completeAuthentication', [
credentials.gaiaId, credentials.email, credentials.password, credentials.gaiaId, credentials.email, credentials.password,
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "chrome/browser/chromeos/lock_screen_apps/state_controller.h" #include "chrome/browser/chromeos/lock_screen_apps/state_controller.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h" #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h"
#include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/hwid_checker.h" #include "chrome/browser/chromeos/login/hwid_checker.h"
#include "chrome/browser/chromeos/login/lock/screen_locker.h" #include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h"
...@@ -501,6 +502,8 @@ void SigninScreenHandler::DeclareLocalizedValues( ...@@ -501,6 +502,8 @@ void SigninScreenHandler::DeclareLocalizedValues(
void SigninScreenHandler::RegisterMessages() { void SigninScreenHandler::RegisterMessages() {
AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser); AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser);
AddCallback("completeOfflineAuthentication",
&SigninScreenHandler::HandleCompleteOfflineAuthentication);
AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito); AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito);
AddCallback("showSupervisedUserCreationScreen", AddCallback("showSupervisedUserCreationScreen",
&SigninScreenHandler::HandleShowSupervisedUserCreationScreen); &SigninScreenHandler::HandleShowSupervisedUserCreationScreen);
...@@ -1189,6 +1192,12 @@ void SigninScreenHandler::UpdateAddButtonStatus() { ...@@ -1189,6 +1192,12 @@ void SigninScreenHandler::UpdateAddButtonStatus() {
void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
const std::string& password, const std::string& password,
bool authenticated_by_pin) { bool authenticated_by_pin) {
AuthenticateExistingUser(account_id, password, authenticated_by_pin);
}
void SigninScreenHandler::AuthenticateExistingUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin) {
if (!delegate_) if (!delegate_)
return; return;
DCHECK_EQ(account_id.GetUserEmail(), DCHECK_EQ(account_id.GetUserEmail(),
...@@ -1199,7 +1208,7 @@ void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, ...@@ -1199,7 +1208,7 @@ void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
DCHECK(user); DCHECK(user);
UserContext user_context; UserContext user_context;
if (!user) { if (!user) {
LOG(ERROR) << "HandleAuthenticateUser: User not found! account type=" LOG(ERROR) << "AuthenticateExistingUser: User not found! account type="
<< AccountId::AccountTypeToString(account_id.GetAccountType()); << AccountId::AccountTypeToString(account_id.GetAccountType());
const user_manager::UserType user_type = const user_manager::UserType user_type =
(account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY) (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY)
...@@ -1226,6 +1235,28 @@ void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id, ...@@ -1226,6 +1235,28 @@ void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
UpdatePinKeyboardState(account_id); UpdatePinKeyboardState(account_id);
} }
void SigninScreenHandler::HandleCompleteOfflineAuthentication(
const std::string& email,
const std::string& password) {
const std::string sanitized_email = gaia::SanitizeEmail(email);
const AccountId account_id = user_manager::known_user::GetAccountId(
sanitized_email, std::string() /* id */, AccountType::UNKNOWN);
const user_manager::User* user =
user_manager::UserManager::Get()->FindUser(account_id);
if (!user) {
LOG(ERROR)
<< "HandleCompleteOfflineAuthentication: User not found! account type="
<< AccountId::AccountTypeToString(account_id.GetAccountType());
LoginDisplayHost::default_host()->GetLoginDisplay()->ShowError(
IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, 1,
HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
return;
}
AuthenticateExistingUser(account_id, password,
false /* authenticated_by_pin */);
}
void SigninScreenHandler::HandleLaunchIncognito() { void SigninScreenHandler::HandleLaunchIncognito() {
UserContext context(user_manager::USER_TYPE_GUEST, EmptyAccountId()); UserContext context(user_manager::USER_TYPE_GUEST, EmptyAccountId());
if (delegate_) if (delegate_)
......
...@@ -361,6 +361,8 @@ class SigninScreenHandler ...@@ -361,6 +361,8 @@ class SigninScreenHandler
void HandleAuthenticateUser(const AccountId& account_id, void HandleAuthenticateUser(const AccountId& account_id,
const std::string& password, const std::string& password,
bool authenticated_by_pin); bool authenticated_by_pin);
void HandleCompleteOfflineAuthentication(const std::string& email,
const std::string& password);
void HandleAttemptUnlock(const std::string& username); void HandleAttemptUnlock(const std::string& username);
void HandleLaunchIncognito(); void HandleLaunchIncognito();
void HandleLaunchPublicSession(const AccountId& account_id, void HandleLaunchPublicSession(const AccountId& account_id,
...@@ -408,6 +410,11 @@ class SigninScreenHandler ...@@ -408,6 +410,11 @@ class SigninScreenHandler
void HandleNewNoteLaunchAnimationDone(); void HandleNewNoteLaunchAnimationDone();
void HandleCloseLockScreenApp(); void HandleCloseLockScreenApp();
// Implements user sign-in.
void AuthenticateExistingUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin);
// Sends the list of |keyboard_layouts| available for the |locale| that is // Sends the list of |keyboard_layouts| available for the |locale| that is
// currently selected for the public session identified by |user_id|. // currently selected for the public session identified by |user_id|.
void SendPublicSessionKeyboardLayouts( void SendPublicSessionKeyboardLayouts(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment