Commit 4de44aba authored by siyua's avatar siyua Committed by Commit Bot

[Autofill Auth UI] Modify backend logic for Auth dialog

Change how backend cancels ongoing process when user
presses the cancel button in the WebAuthn verify pending dialog.

This change will explicitly reset the full card request is there is one.

Bug: 949269
Change-Id: Icc4cc1597bcf31b0d42879a3cdf826b750ff15f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918139
Commit-Queue: Siyu An <siyua@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#717195}
parent e9f31e15
......@@ -394,6 +394,13 @@ void CreditCardAccessManager::Authenticate(bool get_unmask_details_returned) {
#if defined(OS_IOS)
NOTREACHED();
#else
// If |is_authentication_in_progress_| is false, it means the process has
// been cancelled via the verify pending dialog. Do not run
// CreditCardFIDOAuthenticator::Authenticate in this case (should not fall
// back to CVC auth either).
if (!is_authentication_in_progress_)
return;
DCHECK(unmask_details_.fido_request_options.is_dict());
GetOrCreateFIDOAuthenticator()->Authenticate(
card_, weak_ptr_factory_.GetWeakPtr(), form_parsed_timestamp_,
......@@ -526,7 +533,7 @@ void CreditCardAccessManager::ShowVerifyPendingDialog() {
}
void CreditCardAccessManager::OnDidCancelCardVerification() {
payments_client_->CancelRequest();
GetOrCreateFIDOAuthenticator()->CancelVerification();
unmask_details_request_in_progress_ = false;
is_authentication_in_progress_ = false;
}
......
......@@ -166,6 +166,15 @@ void CreditCardFIDOAuthenticator::SyncUserOptIn(
is_user_opted_in);
}
void CreditCardFIDOAuthenticator::CancelVerification() {
current_flow_ = NONE_FLOW;
// Full card request may not exist when this function is called. The full card
// request is created in OnDidGetAssertion() but the flow can be cancelled
// before than.
if (full_card_request_)
full_card_request_->OnFIDOVerificationCancelled();
}
FidoAuthenticationStrikeDatabase*
CreditCardFIDOAuthenticator::GetOrCreateFidoAuthenticationStrikeDatabase() {
if (!fido_authentication_strike_database_) {
......
......@@ -108,6 +108,10 @@ class CreditCardFIDOAuthenticator
// Ensures that local user opt-in pref is in-sync with payments server.
void SyncUserOptIn(AutofillClient::UnmaskDetails& unmask_details);
// Cancel the ongoing verification process. Used to reset states in this class
// and in the FullCardRequest if any.
void CancelVerification();
// Retrieves the strike database for offering FIDO authentication.
FidoAuthenticationStrikeDatabase*
GetOrCreateFidoAuthenticationStrikeDatabase();
......
......@@ -233,6 +233,10 @@ void FullCardRequest::OnDidGetRealPan(
}
}
void FullCardRequest::OnFIDOVerificationCancelled() {
Reset();
}
void FullCardRequest::Reset() {
weak_ptr_factory_.InvalidateWeakPtrs();
payments_client_->CancelRequest();
......
......@@ -94,6 +94,10 @@ class FullCardRequest final : public CardUnmaskDelegate {
AutofillClient::PaymentsRpcResult result,
payments::PaymentsClient::UnmaskResponseDetails& response_details);
// Called when verification is cancelled. This is used only by
// CreditCardFIDOAuthenticator to cancel the flow for opted-in users.
void OnFIDOVerificationCancelled();
payments::PaymentsClient::UnmaskResponseDetails unmask_response_details()
const {
return unmask_response_details_;
......
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