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 和云环境,轻松支持高并发、分布式的性能测试; - 性能测试: 兼容 JMeter支持 Kubernetes 和云环境,轻松支持高并发、分布式的性能测试;
- 团队协作: 两级租户体系,天然支持团队协作。 - 团队协作: 两级租户体系,天然支持团队协作。
![产品定位](https://metersphere.io/images/icon/ct-devops.png)
UI 展示: UI 展示:
![UI](https://metersphere.io/images/screenshot/ss07.png) ![UI](https://metersphere.io/images/screenshot/ss07.png)

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,3 @@
alter table user add source varchar(50) null; 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;