parent
fa4fc02626
commit
74e22e08e3
|
@ -29,14 +29,27 @@ Once you have injected the authorization service you use it by calling the `Auth
|
|||
|
||||
In some cases the resource will be your view model, and you can call `AuthorizeAsync` in exactly the same way as you would check during [resource based authorization](resourcebased.md#security-authorization-resource-based-imperative);
|
||||
|
||||
# [ASP.NET Core 2.x](#tab/aspnetcore2x)
|
||||
|
||||
```csharp
|
||||
@if (await AuthorizationService.AuthorizeAsync(User, Model, Operations.Edit))
|
||||
@if ((await AuthorizationService.AuthorizeAsync(User, Model, Operations.Edit)).Succeeded)
|
||||
{
|
||||
<p><a class="btn btn-default" role="button"
|
||||
href="@Url.Action("Edit", "Document", new { id = Model.Id })">Edit</a></p>
|
||||
}
|
||||
```
|
||||
|
||||
# [ASP.NET Core 1.x](#tab/aspnetcore1x)
|
||||
|
||||
```csharp
|
||||
@if (await AuthorizationService.AuthorizeAsync(User, Model, Operations.Edit))
|
||||
{
|
||||
<p><a class="btn btn-default" role="button"
|
||||
href="@Url.Action("Edit", "Document", new { id = Model.Id })">Edit</a></p>
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
Here you can see the model is passed as the resource authorization should take into consideration.
|
||||
|
||||
>[!WARNING]
|
||||
|
|
Loading…
Reference in New Issue