Commit e1bc2730 authored by Manas Verma's avatar Manas Verma Committed by Commit Bot

[Autofill Auth] Resetting pref when user declines WebAuthn offer.

When the user toggles the switch for FIDO authentication, the pref is set to
true and the offer dialog is shown. This CL ensures to reset the pref to false
if the user declines the offer immediately.

Bug: 949269
Change-Id: Idd5424f3972e7785eda672a82fa48753ec98c709
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884312Reviewed-by: default avatarJared Saul <jsaul@google.com>
Commit-Queue: Manas Verma <manasverma@google.com>
Cr-Commit-Position: refs/heads/master@{#710982}
parent fd982466
...@@ -370,6 +370,12 @@ void CreditCardFIDOAuthenticator::OnDidGetOptChangeResult( ...@@ -370,6 +370,12 @@ void CreditCardFIDOAuthenticator::OnDidGetOptChangeResult(
current_flow_ == OPT_OUT_FLOW || current_flow_ == OPT_OUT_FLOW ||
current_flow_ == OPT_IN_WITH_CHALLENGE_FLOW || current_flow_ == OPT_IN_WITH_CHALLENGE_FLOW ||
current_flow_ == FOLLOWUP_AFTER_CVC_AUTH_FLOW); current_flow_ == FOLLOWUP_AFTER_CVC_AUTH_FLOW);
// Update user preference to keep in sync with server.
::autofill::prefs::SetCreditCardFIDOAuthEnabled(
autofill_client_->GetPrefs(),
response.user_is_opted_in.value_or(IsUserOptedIn()));
// End the flow if the server responded with an error. // End the flow if the server responded with an error.
if (result != AutofillClient::PaymentsRpcResult::SUCCESS) { if (result != AutofillClient::PaymentsRpcResult::SUCCESS) {
if (current_flow_ == OPT_IN_FETCH_CHALLENGE_FLOW) if (current_flow_ == OPT_IN_FETCH_CHALLENGE_FLOW)
...@@ -378,12 +384,6 @@ void CreditCardFIDOAuthenticator::OnDidGetOptChangeResult( ...@@ -378,12 +384,6 @@ void CreditCardFIDOAuthenticator::OnDidGetOptChangeResult(
return; return;
} }
// Update user preference to keep in sync with server.
if (response.user_is_opted_in.has_value()) {
::autofill::prefs::SetCreditCardFIDOAuthEnabled(
autofill_client_->GetPrefs(), response.user_is_opted_in.value());
}
// If response contains |creation_options| or |request_options| and the last // If response contains |creation_options| or |request_options| and the last
// opt-in attempt did not include a challenge, then invoke WebAuthn // opt-in attempt did not include a challenge, then invoke WebAuthn
// registration/verification prompt. Otherwise end the flow. // registration/verification prompt. Otherwise end the flow.
...@@ -422,6 +422,8 @@ void CreditCardFIDOAuthenticator::OnWebauthnOfferDialogUserResponse( ...@@ -422,6 +422,8 @@ void CreditCardFIDOAuthenticator::OnWebauthnOfferDialogUserResponse(
current_flow_ = NONE_FLOW; current_flow_ = NONE_FLOW;
GetOrCreateFidoAuthenticationStrikeDatabase()->AddStrikes( GetOrCreateFidoAuthenticationStrikeDatabase()->AddStrikes(
FidoAuthenticationStrikeDatabase::kStrikesToAddWhenOptInOfferDeclined); FidoAuthenticationStrikeDatabase::kStrikesToAddWhenOptInOfferDeclined);
::autofill::prefs::SetCreditCardFIDOAuthEnabled(
autofill_client_->GetPrefs(), false);
} }
} }
......
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