bugfix:请求头带token, SecurityUtils 获取用户id 一直为0 #1195
parent
360fe689b1
commit
42a2772d1a
|
@ -78,6 +78,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
|||
|
||||
// 构建UsernamePasswordAuthenticationToken,这里密码为null,是因为提供了正确的JWT,实现自动登录
|
||||
User user = new User();
|
||||
user.setId(jwtUser.getUserId());
|
||||
user.setUsername(jwtUser.getUserName());
|
||||
user.setPassword(jwtUser.getPassword());
|
||||
Role role = new Role();
|
||||
|
|
|
@ -144,6 +144,7 @@ public class JwtUtils implements InitializingBean {
|
|||
jwtUser.setUserName(username);
|
||||
jwtUser.setPassword(user.getPassword());
|
||||
jwtUser.setRoleId(user.getRole().getId());
|
||||
jwtUser.setUserId(user.getId());
|
||||
|
||||
return jwtUser;
|
||||
} catch (InvalidJwtException e) {
|
||||
|
|
|
@ -21,6 +21,7 @@ public class JwtUser {
|
|||
EXCEPTION
|
||||
}
|
||||
|
||||
private int userId;
|
||||
private String userName;
|
||||
|
||||
private String password;
|
||||
|
@ -29,6 +30,14 @@ public class JwtUser {
|
|||
|
||||
private TokenStatus status;
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue