Skip to content

Commit

Permalink
Smart Lock: Do not start multiple auth attempts.
Browse files Browse the repository at this point in the history
EasyUnlockService previously re-instantiated an EasyUnlockAuthAttempt
every time the user profile picture was tapped or clicked. This was
unnecessary, and caused situations where the account's cryptohome
could not be decrypted.

Bug: 896045
Change-Id: I959ed3209caeb8d83519c8300d863a6288984740
Reviewed-on: https://chromium-review.googlesource.com/c/1285118
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600190}
  • Loading branch information
Ryan Hansberry authored and Commit Bot committed Oct 16, 2018
1 parent b683690 commit faf0b7f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ bool EasyUnlockService::UpdateScreenlockState(ScreenlockState state) {
if (state == ScreenlockState::AUTHENTICATED) {
if (power_monitor_)
power_monitor_->RecordStartUpTime();
} else if (auth_attempt_.get()) {
} else if (auth_attempt_) {
// Clean up existing auth attempt if we can no longer authenticate the
// remote device.
auth_attempt_.reset();
Expand All @@ -381,8 +381,13 @@ void EasyUnlockService::AttemptAuth(const AccountId& account_id) {
const EasyUnlockAuthAttempt::Type auth_attempt_type =
GetType() == TYPE_REGULAR ? EasyUnlockAuthAttempt::TYPE_UNLOCK
: EasyUnlockAuthAttempt::TYPE_SIGNIN;
if (auth_attempt_) {
PA_LOG(INFO) << "Already attempting auth, skipping this request.";
return;
}

if (!GetAccountId().is_valid()) {
LOG(ERROR) << "Empty user account. Refresh token might go bad.";
PA_LOG(ERROR) << "Empty user account. Auth attempt failed.";
return;
}

Expand All @@ -403,7 +408,7 @@ void EasyUnlockService::AttemptAuth(const AccountId& account_id) {
}

void EasyUnlockService::FinalizeUnlock(bool success) {
if (!auth_attempt_.get())
if (!auth_attempt_)
return;

this->OnWillFinalizeUnlock(success);
Expand All @@ -421,8 +426,9 @@ void EasyUnlockService::FinalizeUnlock(bool success) {
}

void EasyUnlockService::FinalizeSignin(const std::string& key) {
if (!auth_attempt_.get())
if (!auth_attempt_)
return;

std::string wrapped_secret = GetWrappedSecret();
if (!wrapped_secret.empty())
auth_attempt_->FinalizeSignin(GetAccountId(), wrapped_secret, key);
Expand Down

0 comments on commit faf0b7f

Please sign in to comment.