| Index: ash/login/lock_screen_controller.cc
|
| diff --git a/ash/login/lock_screen_controller.cc b/ash/login/lock_screen_controller.cc
|
| index 5ff835e034049bb50717f77809a1f13da4591d08..1fc725d17c3f3c98345c4b9062c2802ff40be563 100644
|
| --- a/ash/login/lock_screen_controller.cc
|
| +++ b/ash/login/lock_screen_controller.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "ash/login/lock_screen_controller.h"
|
|
|
| +#include "ash/login/ui/lock_screen.h"
|
| #include "chromeos/cryptohome/system_salt_getter.h"
|
| #include "chromeos/login/auth/user_context.h"
|
|
|
| @@ -17,15 +18,29 @@ void LockScreenController::BindRequest(mojom::LockScreenRequest request) {
|
| bindings_.AddBinding(this, std::move(request));
|
| }
|
|
|
| -void LockScreenController::AuthenticateUser(const AccountId& account_id,
|
| - const std::string& password,
|
| - bool authenticated_by_pin) {
|
| +void LockScreenController::AuthenticateUser(
|
| + const AccountId& account_id,
|
| + const std::string& password,
|
| + bool authenticated_by_pin,
|
| + mojom::LockScreenClient::AuthenticateUserCallback callback) {
|
| if (!lock_screen_client_)
|
| return;
|
|
|
| - chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind(
|
| + // We cannot execute auth requests directly via GetSystemSalt because it
|
| + // expects a base::Callback instance, but |callback| is a base::OnceCallback.
|
| + // Instead, we store |callback| on this object and invoke it locally once we
|
| + // have the system salt.
|
| + DCHECK(!pending_user_auth_) << "More than one concurrent auth attempt";
|
| + pending_user_auth_ = base::BindOnce(
|
| &LockScreenController::DoAuthenticateUser, base::Unretained(this),
|
| - account_id, password, authenticated_by_pin));
|
| + account_id, password, authenticated_by_pin, std::move(callback));
|
| + chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind(
|
| + &LockScreenController::OnGetSystemSalt, base::Unretained(this)));
|
| +}
|
| +
|
| +void LockScreenController::ShowLockScreen(ShowLockScreenCallback on_shown) {
|
| + ::ash::ShowLockScreen();
|
| + std::move(on_shown).Run(true);
|
| }
|
|
|
| void LockScreenController::SetClient(mojom::LockScreenClientPtr client) {
|
| @@ -43,17 +58,23 @@ void LockScreenController::ClearErrors() {
|
| NOTIMPLEMENTED();
|
| }
|
|
|
| -void LockScreenController::DoAuthenticateUser(const AccountId& account_id,
|
| - const std::string& password,
|
| - bool authenticated_by_pin,
|
| - const std::string& system_salt) {
|
| +void LockScreenController::DoAuthenticateUser(
|
| + const AccountId& account_id,
|
| + const std::string& password,
|
| + bool authenticated_by_pin,
|
| + mojom::LockScreenClient::AuthenticateUserCallback callback,
|
| + const std::string& system_salt) {
|
| // Hash password before sending through mojo.
|
| // TODO(xiaoyinh): Pin is hashed differently by using a different salt and
|
| // a different hash algorithm. Update this part in PinStorage.
|
| chromeos::Key key(password);
|
| key.Transform(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt);
|
| - lock_screen_client_->AuthenticateUser(account_id, key.GetSecret(),
|
| - authenticated_by_pin);
|
| + lock_screen_client_->AuthenticateUser(
|
| + account_id, key.GetSecret(), authenticated_by_pin, std::move(callback));
|
| +}
|
| +
|
| +void LockScreenController::OnGetSystemSalt(const std::string& system_salt) {
|
| + std::move(pending_user_auth_).Run(system_salt);
|
| }
|
|
|
| } // namespace ash
|
|
|