Use async-wait pattern in HandleAuthenticateOnceSafeAsync
This commit is contained in:
parent
0314632696
commit
926c7fab4b
|
|
@ -255,18 +255,15 @@ namespace Microsoft.AspNetCore.Authentication
|
||||||
/// This method won't throw exception. Any exception thrown during the authentication will be convert
|
/// This method won't throw exception. Any exception thrown during the authentication will be convert
|
||||||
/// to a AuthenticateResult.
|
/// to a AuthenticateResult.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Task<AuthenticateResult> HandleAuthenticateOnceSafeAsync()
|
protected async Task<AuthenticateResult> HandleAuthenticateOnceSafeAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return HandleAuthenticateOnceAsync().ContinueWith<AuthenticateResult>(
|
return await HandleAuthenticateOnceAsync();
|
||||||
task => task.IsFaulted ? AuthenticateResult.Fail(task.Exception) : task.Result
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// capture exception which is thrown before the task is actually started
|
return AuthenticateResult.Fail(ex);
|
||||||
return Task.FromResult(AuthenticateResult.Fail(ex));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue