Skip to content

Commit d2e4639

Browse files
author
Cagri Yildirim
committed
Resolved feedback.
1 parent b6beef5 commit d2e4639

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

specs/WebAuthenticationRequested.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,25 @@ The developer can provide the authentication credentials on behalf of the user w
3737

3838
```cpp
3939

40-
webview2->add_BasicAuthenticationRequested(
40+
CHECK_HRESULT(webview2->add_BasicAuthenticationRequested(
4141
Callback<ICoreWebView2BasicAuthenticationRequestedEventHandler>(
4242
[this](
4343
ICoreWebView2* sender,
4444
ICoreWebView2BasicAuthenticationRequestedEventArgs* args)
4545
{
4646
wil::com_ptr<ICoreWebView2Deferral> deferral;
47+
48+
// Ensure the event args are retained for the lambda.
4749
wil::com_ptr<ICoreWebView2BasicAuthenticationRequestedEventArgs> web_auth_args = args;
4850
args->GetDeferral(&deferral);
4951
ShowCustomLoginUI().then([web_auth_args, deferral](LPCWSTR userName, LPCWSTR password)
5052
{
5153
wil::com_ptr<ICoreWebView2BasicAuthenticationResponse> basicAuthenticationResponse;
52-
web_auth_args->get_Response(&basicAuthenticationResponse);
53-
basicAuthenticationResponse->put_UserName(userName);
54-
basicAuthenticationResponse->put_Password(password);
54+
CHECK_HRESULT(web_auth_args->get_Response(&basicAuthenticationResponse));
55+
CHECK_HRESULT(basicAuthenticationResponse->put_UserName(userName));
56+
CHECK_HRESULT(basicAuthenticationResponse->put_Password(password));
5557
deferral->Complete();
56-
}
58+
});
5759
5860
return S_OK;
5961
})
@@ -76,13 +78,13 @@ webView.CoreWebView2.BasicAuthenticationRequested += delegate (object sender, Co
7678
The developer can block the authentication request. In this case, the default login dialog prompt will no longer be shown to the user and the server will respond as if the user clicked cancel.
7779

7880
```cpp
79-
webview2->add_BasicAuthenticationRequested(
81+
CHECK_HRESULT(webview2->add_BasicAuthenticationRequested(
8082
Callback<ICoreWebView2BasicAuthenticationRequestedEventHandler>(
8183
[this](
8284
ICoreWebView2* sender,
8385
ICoreWebView2BasicAuthenticationRequestedEventArgs* args)
8486
{
85-
args->put_Cancel(true);
87+
CHECK_HRESULT(args->put_Cancel(true));
8688

8789
return S_OK;
8890
})
@@ -107,10 +109,10 @@ webview2->add_BasicAuthenticationRequested(
107109
ICoreWebView2* sender,
108110
ICoreWebView2BasicAuthenticationRequestedEventArgs* args)
109111
{
110-
args->get_Challenge(&challenge);
112+
CHECK_HRESULT(args->get_Challenge(&challenge));
111113
if (!ValidateChallenge(challenge.get()))
112114
{ // Check the challenge string
113-
args->put_Cancel(true);
115+
CHECK_HRESULT(args->put_Cancel(true));
114116
}
115117
return S_OK;
116118
})
@@ -121,7 +123,7 @@ webview2->add_BasicAuthenticationRequested(
121123
```c#
122124
webView.CoreWebView2.BasicAuthenticationRequested += delegate (object sender, CoreWebView2BasicAuthenticationRequestedEventArgs args)
123125
{
124-
if (ValidateChallenge(args.Challenge))
126+
if (!ValidateChallenge(args.Challenge))
125127
{
126128
args.Cancel = true;
127129
}

0 commit comments

Comments
 (0)