jwt增加用户登录名
This commit is contained in:
@@ -43,6 +43,7 @@ public interface SecurityConstants {
|
||||
* 认证成功后,返回信息包含的内容-
|
||||
*/
|
||||
String USER_ID = "userId";
|
||||
String Login_Name = "userId";
|
||||
String USER_TYPE = "userType";
|
||||
String USER_NAME_KEY = "name";
|
||||
String USER_HEAD_KEY = "headSculpture";
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user