7
7
using Microsoft . AspNetCore . Hosting ;
8
8
using Microsoft . AspNetCore . Mvc . RazorPages ;
9
9
using Microsoft . AspNetCore . StaticFiles ;
10
+ using Microsoft . Extensions . DependencyInjection ;
10
11
using Microsoft . Extensions . FileProviders ;
11
12
using Microsoft . Extensions . Options ;
12
13
@@ -17,6 +18,8 @@ internal class IdentityDefaultUIConfigureOptions :
17
18
IPostConfigureOptions < StaticFileOptions > ,
18
19
IPostConfigureOptions < CookieAuthenticationOptions >
19
20
{
21
+ private const string IdentityUIDefaultAreaName = "Identity" ;
22
+
20
23
public IdentityDefaultUIConfigureOptions ( IHostingEnvironment environment )
21
24
{
22
25
Environment = environment ;
@@ -30,6 +33,8 @@ public void PostConfigure(string name, RazorPagesOptions options)
30
33
options = options ?? throw new ArgumentNullException ( nameof ( options ) ) ;
31
34
32
35
options . AllowAreas = true ;
36
+ options . Conventions . AuthorizeAreaFolder ( IdentityUIDefaultAreaName , "/Account/Manage" ) ;
37
+ options . Conventions . AuthorizeAreaPage ( IdentityUIDefaultAreaName , "/Account/Logout" ) ;
33
38
}
34
39
35
40
public void PostConfigure ( string name , StaticFileOptions options )
@@ -58,9 +63,9 @@ public void PostConfigure(string name, CookieAuthenticationOptions options)
58
63
59
64
if ( string . Equals ( IdentityConstants . ApplicationScheme , name , StringComparison . Ordinal ) )
60
65
{
61
- options . LoginPath = "/Identity /Account/Login";
62
- options . LogoutPath = "/Identity /Account/Logout";
63
- options . AccessDeniedPath = "/Identity /Account/AccessDenied";
66
+ options . LoginPath = $ "/ { IdentityUIDefaultAreaName } /Account/Login";
67
+ options . LogoutPath = $ "/ { IdentityUIDefaultAreaName } /Account/Logout";
68
+ options . AccessDeniedPath = $ "/ { IdentityUIDefaultAreaName } /Account/AccessDenied";
64
69
}
65
70
}
66
71
}
0 commit comments