File tree Expand file tree Collapse file tree
src/OrchardCoreContrib.ContentPermissions/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- namespace Microsoft . AspNetCore . Http ;
1+ using Microsoft . AspNetCore . Authentication . Cookies ;
2+ using Microsoft . AspNetCore . Identity ;
3+ using Microsoft . Extensions . DependencyInjection ;
4+ using Microsoft . Extensions . Options ;
25
6+ namespace Microsoft . AspNetCore . Http ;
7+
8+ // TODO: Move this to OCC.Infrastructure.Abstractions
39internal static class HttpReponseExtensions
410{
5- private const string AccessDeniedPath = "/Error/403" ;
6-
711 public static void RedirectToAccessDeniedPage ( this HttpResponse httpResponse )
812 {
9-
10- // TODO: Check why OC doesn't respects the cookie authentication options
11- //var cookieAuthenticationOptions = httpResponse.HttpContext.RequestServices
12- // .GetService<IOptions<CookieAuthenticationOptions>>().Value;
13+ var cookieAuthenticationOptions = httpResponse . HttpContext . RequestServices
14+ . GetService < IOptionsMonitor < CookieAuthenticationOptions > > ( )
15+ . Get ( IdentityConstants . ApplicationScheme ) ;
1316
1417 httpResponse . StatusCode = StatusCodes . Status403Forbidden ;
15- httpResponse . Redirect ( AccessDeniedPath ) ;
18+ httpResponse . Redirect ( cookieAuthenticationOptions . AccessDeniedPath ) ;
1619 }
1720}
You can’t perform that action at this time.
0 commit comments