Skip to content

Commit d460b5d

Browse files
author
kdeng00
committed
Token modification
Addresses #84. Adding user ID to the access token.
1 parent 66b5944 commit d460b5d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Controllers/Managers/TokenManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Security.Cryptography;
66
using System.Threading.Tasks;
77
using System.IdentityModel.Tokens.Jwt;
8-
using System.Security.Claims;
98
using System.Text;
109

1110
using JWT;
@@ -123,6 +122,8 @@ public LoginResult LoginSymmetric(User user)
123122
tokenResult.TokenType = "Jwt";
124123

125124
var payload = Payload();
125+
payload.Add(new System.Security.Claims.Claim("user_id", user.UserID.ToString(), ClaimValueTypes.Integer));
126+
126127
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["JWT:Secret"]));
127128
var signIn = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
128129
var token = new JwtSecurityToken(
@@ -171,7 +172,7 @@ public bool IsTokenValid(string scope, string accessToken)
171172
return result;
172173
}
173174

174-
public Token? DecodeToken(string accessToken)
175+
public Token DecodeToken(string accessToken)
175176
{
176177
var rsaParams = GetRSAPublic(_publicKey);
177178
Token tok = null;

0 commit comments

Comments
 (0)