summaryrefslogtreecommitdiff
path: root/Controllers/UsersController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Controllers/UsersController.cs')
-rw-r--r--Controllers/UsersController.cs8
1 files changed, 8 insertions, 0 deletions
diff --git a/Controllers/UsersController.cs b/Controllers/UsersController.cs
index d5dded5..5483a6b 100644
--- a/Controllers/UsersController.cs
+++ b/Controllers/UsersController.cs
@@ -54,6 +54,14 @@ namespace IdentityAPI.Controllers {
return StatusCode(400, new { error = "Invalid request body" });
}
+ [HttpGet("refresh")]
+ [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
+ public async Task<IActionResult> Refresh() {
+ var user = await _manager.FindByEmailAsync(HttpContext.User.Claims.Where(c => c.Type.Contains("email")).FirstOrDefault().Value);
+
+ return Ok(new { Token = GenerateToken(user) });
+ }
+
private string GenerateToken(IdentityUser user) {
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["Jwt:Key"]));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);