Merge remote-tracking branch 'origin/master'

This commit is contained in:
Captain.B 2020-07-14 17:27:04 +08:00
commit a483732635
6 changed files with 22 additions and 8 deletions

View File

@ -10,6 +10,8 @@ MeterSphere 是一站式的开源企业级持续测试平台,涵盖测试跟
- 性能测试: 兼容 JMeter支持 Kubernetes 和云环境,轻松支持高并发、分布式的性能测试;
- 团队协作: 两级租户体系,天然支持团队协作。
![产品定位](https://metersphere.io/images/icon/ct-devops.png)
UI 展示:
![UI](https://metersphere.io/images/screenshot/ss07.png)

View File

@ -293,7 +293,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.41</version>
<version>8.0.16</version>
</dependency>
<dependency>
<groupId>com.itfsw</groupId>

View File

@ -1,5 +1,5 @@
package io.metersphere.commons.constants;
public enum UserSource {
Local, Ldap
LOCAL, LDAP
}

View File

@ -56,8 +56,8 @@ public class LdapController {
user.setName(username);
user.setEmail(email);
user.setPassword(password);
user.setSource(UserSource.Ldap.name());
userService.createUser(user);
user.setSource(UserSource.LDAP.name());
userService.addLdapUser(user);
} else {
request.setUsername(u.getId());
request.setPassword(u.getPassword());

View File

@ -138,17 +138,29 @@ public class UserService {
user.setUpdateTime(System.currentTimeMillis());
// 默认1:启用状态
user.setStatus(UserStatus.NORMAL);
user.setSource(UserSource.Local.name());
user.setSource(UserSource.LOCAL.name());
// 密码使用 MD5
user.setPassword(CodingUtil.md5(user.getPassword()));
checkEmailIsExist(user.getEmail());
userMapper.insertSelective(user);
}
public void addLdapUser(User user) {
user.setCreateTime(System.currentTimeMillis());
user.setUpdateTime(System.currentTimeMillis());
user.setStatus(UserStatus.NORMAL);
checkEmailIsExist(user.getEmail());
userMapper.insertSelective(user);
}
private void checkEmailIsExist(String email) {
UserExample userExample = new UserExample();
UserExample.Criteria criteria = userExample.createCriteria();
criteria.andEmailEqualTo(user.getEmail());
criteria.andEmailEqualTo(email);
List<User> userList = userMapper.selectByExample(userExample);
if (!CollectionUtils.isEmpty(userList)) {
MSException.throwException(Translator.get("user_email_already_exists"));
}
userMapper.insertSelective(user);
}
public UserDTO getUserDTO(String userId) {

View File

@ -1,3 +1,3 @@
alter table user add source varchar(50) null;
update user set source = 'Local' where source is null;
update user set source = 'LOCAL' where source is null;