mirror of https://github.com/elunez/eladmin
Merge branch 'master' into deploy
commit
c310af6169
|
@ -111,8 +111,6 @@ public class AuthController {
|
||||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||||
// 生成令牌
|
// 生成令牌
|
||||||
String token = tokenProvider.createToken(jwtUser);
|
String token = tokenProvider.createToken(jwtUser);
|
||||||
// 将密码设置为空
|
|
||||||
jwtUser.setPassword(null);
|
|
||||||
// 返回 token 与 用户信息
|
// 返回 token 与 用户信息
|
||||||
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
|
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
|
||||||
put("token", properties.getTokenStartWith() + token);
|
put("token", properties.getTokenStartWith() + token);
|
||||||
|
@ -132,8 +130,6 @@ public class AuthController {
|
||||||
@GetMapping(value = "/info")
|
@GetMapping(value = "/info")
|
||||||
public ResponseEntity<UserDetails> getUserInfo() {
|
public ResponseEntity<UserDetails> getUserInfo() {
|
||||||
JwtUserDto jwtUser = (JwtUserDto) SecurityUtils.getCurrentUser();
|
JwtUserDto jwtUser = (JwtUserDto) SecurityUtils.getCurrentUser();
|
||||||
// 将密码设置为空
|
|
||||||
jwtUser.setPassword(null);
|
|
||||||
return ResponseEntity.ok(jwtUser);
|
return ResponseEntity.ok(jwtUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||||
// 获取用户的权限
|
// 获取用户的权限
|
||||||
List<AuthorityDto> authorities = roleService.buildPermissions(user);
|
List<AuthorityDto> authorities = roleService.buildPermissions(user);
|
||||||
// 初始化JwtUserDto
|
// 初始化JwtUserDto
|
||||||
jwtUserDto = new JwtUserDto(user, dataService.getDeptIds(user), authorities, user.getPassword());
|
jwtUserDto = new JwtUserDto(user, dataService.getDeptIds(user), authorities);
|
||||||
// 添加缓存数据
|
// 添加缓存数据
|
||||||
userCacheManager.addUserCache(username, jwtUserDto);
|
userCacheManager.addUserCache(username, jwtUserDto);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
import me.zhengjie.modules.system.service.dto.UserDto;
|
import me.zhengjie.modules.system.service.dto.UserDto;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -43,14 +42,16 @@ public class JwtUserDto implements UserDetails {
|
||||||
@ApiModelProperty(value = "角色权限")
|
@ApiModelProperty(value = "角色权限")
|
||||||
private final List<AuthorityDto> authorities;
|
private final List<AuthorityDto> authorities;
|
||||||
|
|
||||||
@Setter
|
|
||||||
@ApiModelProperty(value = "密码")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
public Set<String> getRoles() {
|
public Set<String> getRoles() {
|
||||||
return authorities.stream().map(AuthorityDto::getAuthority).collect(Collectors.toSet());
|
return authorities.stream().map(AuthorityDto::getAuthority).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JSONField(serialize = false)
|
||||||
|
public String getPassword() {
|
||||||
|
return user.getPassword();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@JSONField(serialize = false)
|
@JSONField(serialize = false)
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class UserDto extends BaseDTO implements Serializable {
|
||||||
@ApiModelProperty(value = "头像路径")
|
@ApiModelProperty(value = "头像路径")
|
||||||
private String avatarPath;
|
private String avatarPath;
|
||||||
|
|
||||||
@JSONField(serialize = false)
|
|
||||||
@ApiModelProperty(value = "密码")
|
@ApiModelProperty(value = "密码")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue