diff options
author | Danijel Andjelkovic <adanijel99@gmail.com> | 2022-03-12 15:38:23 +0000 |
---|---|---|
committer | Danijel Andjelkovic <adanijel99@gmail.com> | 2022-03-12 15:38:23 +0000 |
commit | a404c208274605850fcf1f97e983dabc3b187cad (patch) | |
tree | 9d3cb0e49ad1c560f3843086afe7868d501e3b49 /backend/api/api/Controllers/AuthController.cs | |
parent | 2b8c174e0d8ee5a64b22f7a4e05a47365fe33947 (diff) | |
parent | 6ef6177737a2277540ef620b2cf308ed503db975 (diff) |
Merge branch 'Jwt-renew' into 'dev'
Omoguceno refreshati jwt token.
See merge request igrannonica/neuronstellar!21
Diffstat (limited to 'backend/api/api/Controllers/AuthController.cs')
-rw-r--r-- | backend/api/api/Controllers/AuthController.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/backend/api/api/Controllers/AuthController.cs b/backend/api/api/Controllers/AuthController.cs index e1601815..6dfe483a 100644 --- a/backend/api/api/Controllers/AuthController.cs +++ b/backend/api/api/Controllers/AuthController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using api.Services; using Microsoft.AspNetCore.Authorization; +using Microsoft.Net.Http.Headers; namespace api.Controllers { @@ -37,6 +38,21 @@ namespace api.Controllers return Ok("works"); } + [HttpPost("renewJwt")] + [Authorize(Roles = "User")] + public async Task<ActionResult<string>> RenewJwt() { + var authorization = Request.Headers[HeaderNames.Authorization]; + + var newToken=_auth.RenewToken(authorization); + if(newToken== null) + return BadRequest(); + return Ok(newToken); + + + + + } + } |