5
5
using System . Collections . Generic ;
6
6
using System . Threading . Tasks ;
7
7
using Microsoft . AspNetCore . Authentication ;
8
+ using Microsoft . AspNetCore . Http ;
8
9
using Microsoft . AspNetCore . Mvc . Core ;
9
10
using Microsoft . Extensions . DependencyInjection ;
10
11
using Microsoft . Extensions . Logging ;
@@ -14,7 +15,7 @@ namespace Microsoft.AspNetCore.Mvc
14
15
/// <summary>
15
16
/// An <see cref="ActionResult"/> that on execution invokes <see cref="M:HttpContext.SignOutAsync"/>.
16
17
/// </summary>
17
- public class SignOutResult : ActionResult
18
+ public class SignOutResult : ActionResult , IResult
18
19
{
19
20
/// <summary>
20
21
/// Initializes a new instance of <see cref="SignOutResult"/> with the default sign out scheme.
@@ -88,13 +89,24 @@ public SignOutResult(IList<string> authenticationSchemes, AuthenticationProperti
88
89
public AuthenticationProperties ? Properties { get ; set ; }
89
90
90
91
/// <inheritdoc />
91
- public override async Task ExecuteResultAsync ( ActionContext context )
92
+ public override Task ExecuteResultAsync ( ActionContext context )
92
93
{
93
94
if ( context == null )
94
95
{
95
96
throw new ArgumentNullException ( nameof ( context ) ) ;
96
97
}
97
98
99
+ return ExecuteAsync ( context . HttpContext ) ;
100
+ }
101
+
102
+ /// <inheritdoc />
103
+ Task IResult . ExecuteAsync ( HttpContext httpContext )
104
+ {
105
+ return ExecuteAsync ( httpContext ) ;
106
+ }
107
+
108
+ private async Task ExecuteAsync ( HttpContext httpContext )
109
+ {
98
110
if ( AuthenticationSchemes == null )
99
111
{
100
112
throw new InvalidOperationException (
@@ -103,20 +115,20 @@ public override async Task ExecuteResultAsync(ActionContext context)
103
115
/* type: */ nameof ( SignOutResult ) ) ) ;
104
116
}
105
117
106
- var loggerFactory = context . HttpContext . RequestServices . GetRequiredService < ILoggerFactory > ( ) ;
118
+ var loggerFactory = httpContext . RequestServices . GetRequiredService < ILoggerFactory > ( ) ;
107
119
var logger = loggerFactory . CreateLogger < SignOutResult > ( ) ;
108
120
109
121
logger . SignOutResultExecuting ( AuthenticationSchemes ) ;
110
122
111
123
if ( AuthenticationSchemes . Count == 0 )
112
124
{
113
- await context . HttpContext . SignOutAsync ( Properties ) ;
125
+ await httpContext . SignOutAsync ( Properties ) ;
114
126
}
115
127
else
116
128
{
117
129
for ( var i = 0 ; i < AuthenticationSchemes . Count ; i ++ )
118
130
{
119
- await context . HttpContext . SignOutAsync ( AuthenticationSchemes [ i ] , Properties ) ;
131
+ await httpContext . SignOutAsync ( AuthenticationSchemes [ i ] , Properties ) ;
120
132
}
121
133
}
122
134
}
0 commit comments