Created
May 29, 2018 22:06
-
-
Save wellingtonjhn/23be96bf91632833090e7dac2f519bbd to your computer and use it in GitHub Desktop.
Authorize Attribute with Policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Route("api/[controller]"), Authorize(Roles = "Administrator")] | |
| public class AdministrationController : Controller | |
| { | |
| // ... restante do código omitido | |
| [HttpDelete, Route("accounts/{accountId}"), Authorize(Policy = "DeleteUserPolicy")] | |
| public async Task<IActionResult> DeleteAccount(Guid accountId) | |
| { | |
| var command = new RemoveAccount(accountId); | |
| var response = await _mediator.Send(command); | |
| if (response.HasMessages) | |
| { | |
| return BadRequest(response.Messages); | |
| } | |
| return Ok(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment