jwt增加用户登录名

This commit is contained in:
2025-08-05 20:33:32 +08:00
parent 2454d84919
commit f069a16e43
2 changed files with 4 additions and 2 deletions

View File

@@ -34,14 +34,15 @@ public class JwtUtil {
*/
private final static String JWT_ISS = "NJCN";
public static String getAccessToken(String userId) {
public static String getAccessToken(String userId,String loginName) {
Map<String, Object> headers = new HashMap<>();
headers.put("typ", "JWT");
headers.put("alg", "HS256");
Map<String, Object> payload = new HashMap<>();
payload.put(SecurityConstants.USER_ID, userId);
payload.put(SecurityConstants.Login_Name, loginName);
// 永不过期
payload.put("exp", Instant.now().plusSeconds(DAY_SECOND * Integer.MAX_VALUE).getEpochSecond());
payload.put("exp", "4910070710");
payload.put("sub", SUBJECT);
payload.put("iss", JWT_ISS);
payload.put("iat", Instant.now().getEpochSecond());