File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
sessions/Season-02/CollectionWebsite/1209-Auth/src Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 38
38
// options.AccessDeniedPath = "/Identity/Account/AccessDenied";
39
39
// options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
40
40
// });
41
- // builder.Services.AddAuthorization();
41
+ builder . Services . AddAuthorization ( options => {
42
+ options . AddPolicy ( "CanEdit" , policy =>
43
+ {
44
+ policy . RequireAuthenticatedUser ( ) ;
45
+ } ) ;
46
+ } ) ;
42
47
43
48
44
49
builder . Services . AddEndpointsApiExplorer ( ) ;
Original file line number Diff line number Diff line change 11
11
asp-action =" Details" asp-route-id =" @Model.Id" >
12
12
@Model.Name
13
13
</a >
14
- @if (User . Identity . IsAuthenticated ) {
14
+ @if (( await AuthService . AuthorizeAsync ( User , " CanEdit " )). Succeeded ) {
15
15
< a asp - controller = " CollectionItems"
16
16
asp - action = " Edit" asp - route - id = " @Model.Id" >
17
17
< span class = " oi oi-pencil" title = " pencil" aria - hidden = " true" >< / span >
You can’t perform that action at this time.
0 commit comments