Skip to content

Commit 3967cac

Browse files
committed
fix(core): 修复管理员修改用户密码导致明文
1 parent d5eac78 commit 3967cac

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

core/datacap-common/src/main/java/io/edurt/datacap/common/enums/ServiceState.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ public enum ServiceState
77
{
88
SOURCE_NOT_FOUND(1001, "Source does not exist"),
99
SOURCE_NOT_SUPPORTED(1002, "The current data source is not supported"),
10-
SOURCE_NOT_SUPPORTED_PIPELINE(1003, "The current data source does not support pipeline"),
11-
SOURCE_NOT_SUPPORTED_PIPELINE_TYPE(1004, "The current data source does not support pipeline type"),
1210
PLUGIN_NOT_FOUND(2001, "Plugin dose not exists"),
1311
PLUGIN_EXECUTE_FAILED(2002, "Plugin execute failed"),
1412
PLUGIN_ONLY_ONE_TEMPLATE(2003, "Plug-ins support only templates with the same name"),

core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/UserServiceImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.edurt.datacap.service.initializer.InitializerConfigure;
3030
import io.edurt.datacap.service.model.AiModel;
3131
import io.edurt.datacap.service.record.TreeRecord;
32+
import io.edurt.datacap.service.repository.BaseRepository;
3233
import io.edurt.datacap.service.repository.RoleRepository;
3334
import io.edurt.datacap.service.repository.SourceRepository;
3435
import io.edurt.datacap.service.repository.UserRepository;
@@ -115,7 +116,7 @@ public CommonResponse<UserEntity> saveOrUpdate(UserEntity configure)
115116
Set<RoleEntity> roles = new HashSet<>();
116117
if (ObjectUtils.isEmpty(userRoles)) {
117118
Optional<RoleEntity> userRoleOptional = roleRepository.findByName("User");
118-
if (!userRoleOptional.isPresent()) {
119+
if (userRoleOptional.isEmpty()) {
119120
return CommonResponse.failure(ServiceState.USER_ROLE_NOT_FOUND);
120121
}
121122
roles.add(userRoleOptional.get());
@@ -135,6 +136,15 @@ public CommonResponse<UserEntity> saveOrUpdate(UserEntity configure)
135136
return CommonResponse.success(userRepository.save(configure));
136137
}
137138

139+
@Override
140+
public CommonResponse<UserEntity> saveOrUpdate(BaseRepository<UserEntity, Long> repository, UserEntity configure)
141+
{
142+
if (configure.getId() != null) {
143+
configure.setPassword(encoder.encode(configure.getPassword()));
144+
}
145+
return this.saveOrUpdate(configure);
146+
}
147+
138148
@AuditUserLog
139149
@Override
140150
public CommonResponse<Object> authenticate(UserEntity configure)

0 commit comments

Comments
 (0)