feat(auth): SysAuthHandler 生成 ADMIN 类型 Token,AuthResponse 增加 userType
- SysAuthHandler 登录时显式传入 userType=ADMIN - AuthResponse 增加 userType 字段及四参数构造函数 - 旧三参数构造函数默认 userType=ADMIN
This commit is contained in:
+19
@@ -20,6 +20,9 @@ public class AuthResponse {
|
||||
@Schema(description = "用户名", example = "admin")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "用户类型", example = "ADMIN")
|
||||
private String userType;
|
||||
|
||||
public AuthResponse() {
|
||||
}
|
||||
|
||||
@@ -27,6 +30,14 @@ public class AuthResponse {
|
||||
this.token = token;
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.userType = "ADMIN";
|
||||
}
|
||||
|
||||
public AuthResponse(String token, Long userId, String username, String userType) {
|
||||
this.token = token;
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
@@ -52,4 +63,12 @@ public class AuthResponse {
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -133,8 +133,9 @@ public class SysAuthHandler {
|
||||
.generateToken(
|
||||
user.getUsername(),
|
||||
user.getId(),
|
||||
roleKeys);
|
||||
logger.info("用户登录成功: username={}, userId={}, roles={}",
|
||||
roleKeys,
|
||||
"ADMIN");
|
||||
logger.info("用户登录成功: username={}, userId={}, roles={}, userType=ADMIN",
|
||||
user.getUsername(),
|
||||
user.getId(),
|
||||
roleKeys);
|
||||
@@ -146,7 +147,8 @@ public class SysAuthHandler {
|
||||
AuthResponse response = new AuthResponse(
|
||||
token,
|
||||
user.getId(),
|
||||
user.getUsername());
|
||||
user.getUsername(),
|
||||
"ADMIN");
|
||||
return ServerResponse.ok()
|
||||
.bodyValue(response);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user