Created
May 29, 2018 22:34
-
-
Save wellingtonjhn/0c25e94c515a10e6929a60777b947916 to your computer and use it in GitHub Desktop.
Authorization Service Example
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]")] | |
| public class ProfileController : Controller | |
| { | |
| private readonly IAuthorizationService _authorizationService; | |
| public CustomersController(IAuthorizationService authorizationService) | |
| { | |
| _authorizationService = authorizationService; | |
| } | |
| [HttpPut, Route("email")] | |
| public async Task<IActionResult> ChangeUserEmail([FromBody] ChangeUserEmail command) | |
| { | |
| var authorizationResult = await _authorizationService | |
| .AuthorizeAsync(HttpContext.User, command.EletronicSignature, new EletronicSignatureRequirement()); | |
| if (!authorizationResult.Succeeded) | |
| { | |
| return BadRequest("Assinatura eletrônica inválida"); | |
| } | |
| // ... restante do código omitido | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment