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() {
} else if (credentials.useOffline) {
this.email = credentials.email;
chrome.send(
'authenticateUser',
[credentials.email, credentials.password, false]);
'completeOfflineAuthentication',
[credentials.email, credentials.password]);
} else if (credentials.authCode) {
chrome.send('completeAuthentication', [
credentials.gaiaId, credentials.email, credentials.password,
......
......@@ -41,6 +41,7 @@
#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/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/lock/screen_locker.h"
#include "chrome/browser/chromeos/login/lock/webui_screen_locker.h"
......@@ -501,6 +502,8 @@ void SigninScreenHandler::DeclareLocalizedValues(
void SigninScreenHandler::RegisterMessages() {
AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser);
AddCallback("completeOfflineAuthentication",
&SigninScreenHandler::HandleCompleteOfflineAuthentication);
AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito);
AddCallback("showSupervisedUserCreationScreen",
&SigninScreenHandler::HandleShowSupervisedUserCreationScreen);
......@@ -1189,6 +1192,12 @@ void SigninScreenHandler::UpdateAddButtonStatus() {
void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
const std::string& password,
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_)
return;
DCHECK_EQ(account_id.GetUserEmail(),
......@@ -1199,7 +1208,7 @@ void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
DCHECK(user);
UserContext user_context;
if (!user) {
LOG(ERROR) << "HandleAuthenticateUser: User not found! account type="
LOG(ERROR) << "AuthenticateExistingUser: User not found! account type="
<< AccountId::AccountTypeToString(account_id.GetAccountType());
const user_manager::UserType user_type =
(account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY)
......@@ -1226,6 +1235,28 @@ void SigninScreenHandler::HandleAuthenticateUser(const AccountId& 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() {
UserContext context(user_manager::USER_TYPE_GUEST, EmptyAccountId());
if (delegate_)
......
......@@ -361,6 +361,8 @@ class SigninScreenHandler
void HandleAuthenticateUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin);
void HandleCompleteOfflineAuthentication(const std::string& email,
const std::string& password);
void HandleAttemptUnlock(const std::string& username);
void HandleLaunchIncognito();
void HandleLaunchPublicSession(const AccountId& account_id,
......@@ -408,6 +410,11 @@ class SigninScreenHandler
void HandleNewNoteLaunchAnimationDone();
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
// currently selected for the public session identified by |user_id|.
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