aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/api/api/Models/JwtToken.cs28
1 files changed, 5 insertions, 23 deletions
diff --git a/backend/api/api/Models/JwtToken.cs b/backend/api/api/Models/JwtToken.cs
index 31ecca10..7cbd6f54 100644
--- a/backend/api/api/Models/JwtToken.cs
+++ b/backend/api/api/Models/JwtToken.cs
@@ -33,31 +33,13 @@ namespace api.Models
public string RenewToken(string existingToken)
{
- if (existingToken == null)
+ var userName = TokenToUsername(existingToken);
+ if (userName == null)
return null;
- var tokenHandler = new JwtSecurityTokenHandler();
- var key= Encoding.ASCII.GetBytes(_configuration.GetSection("AppSettings:JwtToken").Value);
- try
- {
- tokenHandler.ValidateToken(existingToken, new TokenValidationParameters
- {
- ValidateIssuerSigningKey = true,
- IssuerSigningKey = new SymmetricSecurityKey(key),
- ValidateIssuer = false,
- ValidateAudience = false,
- }, out SecurityToken validatedToken);
-
- var jwtToken = (JwtSecurityToken)validatedToken;
- var userName =jwtToken.Claims.First(x => x.Type == "name").Value;
- var authUser = new AuthRequest();
- authUser.UserName = userName;
+ var authUser = new AuthRequest();
+ authUser.UserName = userName;
- return GenToken(authUser);
- }
- catch
- {
- return null;
- }
+ return GenToken(authUser);
}