|
@@ -11,6 +11,7 @@ import cn.com.qmth.examcloud.commons.util.SHA256;
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.UserDomain;
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.UserDomain;
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.UserFormDomain;
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.UserFormDomain;
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.base.util.BaseUtil;
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
@@ -30,7 +31,6 @@ import com.google.common.collect.Maps;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
-import org.apache.commons.lang.StringEscapeUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
@@ -535,6 +535,11 @@ public class UserController extends ControllerSupport {
|
|
|
|
|
|
trim(userForm, true);
|
|
trim(userForm, true);
|
|
userForm.setId(null);
|
|
userForm.setId(null);
|
|
|
|
+
|
|
|
|
+ if (!BaseUtil.checkPassword(userForm.getPassword())) {
|
|
|
|
+ throw new StatusException("密码至少包含大写字母、小写字母、数字、特殊符号中的三种,且长度限制在6-10位!");
|
|
|
|
+ }
|
|
|
|
+
|
|
Map<String, Object> ret = saveUser(userForm);
|
|
Map<String, Object> ret = saveUser(userForm);
|
|
|
|
|
|
ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), AdminOperateType.TYPE6.getDesc(), "用户ID:" + ret.get("userId")));
|
|
ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), AdminOperateType.TYPE6.getDesc(), "用户ID:" + ret.get("userId")));
|
|
@@ -736,26 +741,36 @@ public class UserController extends ControllerSupport {
|
|
throw new StatusException("150410", "超级管理员账号不允许修改");
|
|
throw new StatusException("150410", "超级管理员账号不允许修改");
|
|
}
|
|
}
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
|
|
+ if (user == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ user.setPasswordWeak(true);
|
|
user.setPassword(ByteUtil.toHexAscii(SHA256.encode(user.getLoginName() + BasicConsts.DEFAULT_PASSWORD)));
|
|
user.setPassword(ByteUtil.toHexAscii(SHA256.encode(user.getLoginName() + BasicConsts.DEFAULT_PASSWORD)));
|
|
userRepo.save(user);
|
|
userRepo.save(user);
|
|
}
|
|
}
|
|
User accessUser = getAccessUser();
|
|
User accessUser = getAccessUser();
|
|
ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), AdminOperateType.TYPE8.getDesc(), "用户ID:" + id));
|
|
ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), AdminOperateType.TYPE8.getDesc(), "用户ID:" + id));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@ApiOperation(value = "批量重置用户密码", notes = "重置密码")
|
|
@ApiOperation(value = "批量重置用户密码", notes = "重置密码")
|
|
@PostMapping("/resetPass")
|
|
@PostMapping("/resetPass")
|
|
@Transactional
|
|
@Transactional
|
|
public void resetPassBatch(@RequestParam Long[] ids) {
|
|
public void resetPassBatch(@RequestParam Long[] ids) {
|
|
- if(ids==null||ids.length==0) {
|
|
|
|
- throw new StatusException("用户ID不能为空");
|
|
|
|
- }
|
|
|
|
|
|
+ if (ids == null || ids.length == 0) {
|
|
|
|
+ throw new StatusException("用户ID不能为空");
|
|
|
|
+ }
|
|
for (Long userId : ids) {
|
|
for (Long userId : ids) {
|
|
if (isSuperAdmin(userId)) {
|
|
if (isSuperAdmin(userId)) {
|
|
throw new StatusException("150410", "超级管理员账号不允许修改");
|
|
throw new StatusException("150410", "超级管理员账号不允许修改");
|
|
}
|
|
}
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
|
|
+ if (user == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
user.setPassword(ByteUtil.toHexAscii(SHA256.encode(user.getLoginName() + BasicConsts.DEFAULT_PASSWORD)));
|
|
user.setPassword(ByteUtil.toHexAscii(SHA256.encode(user.getLoginName() + BasicConsts.DEFAULT_PASSWORD)));
|
|
|
|
+ user.setPasswordWeak(true);
|
|
userRepo.save(user);
|
|
userRepo.save(user);
|
|
}
|
|
}
|
|
User accessUser = getAccessUser();
|
|
User accessUser = getAccessUser();
|
|
@@ -774,6 +789,10 @@ public class UserController extends ControllerSupport {
|
|
throw new StatusException("150410", "超级管理员账号不允许修改");
|
|
throw new StatusException("150410", "超级管理员账号不允许修改");
|
|
}
|
|
}
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
|
|
+ if (user == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
user.setEnable(true);
|
|
user.setEnable(true);
|
|
userRepo.save(user);
|
|
userRepo.save(user);
|
|
ret.add(user.getId() + ":" + user.getName());
|
|
ret.add(user.getId() + ":" + user.getName());
|
|
@@ -795,6 +814,10 @@ public class UserController extends ControllerSupport {
|
|
throw new StatusException("150410", "超级管理员账号不允许修改");
|
|
throw new StatusException("150410", "超级管理员账号不允许修改");
|
|
}
|
|
}
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
|
|
+ if (user == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
user.setEnable(false);
|
|
user.setEnable(false);
|
|
userRepo.save(user);
|
|
userRepo.save(user);
|
|
ret.add(user.getId() + ":" + user.getName());
|
|
ret.add(user.getId() + ":" + user.getName());
|
|
@@ -816,12 +839,17 @@ public class UserController extends ControllerSupport {
|
|
public void updatePass(@RequestParam String password) {
|
|
public void updatePass(@RequestParam String password) {
|
|
User accessUser = getAccessUser();
|
|
User accessUser = getAccessUser();
|
|
Long userId = accessUser.getUserId();
|
|
Long userId = accessUser.getUserId();
|
|
- if (password.length() < 6) {
|
|
|
|
- throw new StatusException("150411", "密码长度至少6位");
|
|
|
|
|
|
+
|
|
|
|
+ // if (password.length() < 6) {
|
|
|
|
+ // throw new StatusException("150411", "密码长度至少6位");
|
|
|
|
+ // }
|
|
|
|
+ if (!BaseUtil.checkPassword(password)) {
|
|
|
|
+ throw new StatusException("密码至少包含大写字母、小写字母、数字、特殊符号中的三种,且长度限制在6-10位!");
|
|
}
|
|
}
|
|
|
|
+
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
UserEntity user = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
- String realPassword = StringEscapeUtils.unescapeJavaScript(password);
|
|
|
|
- byte[] bytes = SHA256.encode(user.getLoginName() + realPassword);
|
|
|
|
|
|
+ // String realPassword = StringEscapeUtils.unescapeJavaScript(password);
|
|
|
|
+ byte[] bytes = SHA256.encode(user.getLoginName() + password);
|
|
String encodePassword = ByteUtil.toHexAscii(bytes);
|
|
String encodePassword = ByteUtil.toHexAscii(bytes);
|
|
int ret = userRepo.updatePasswordById(userId, encodePassword);
|
|
int ret = userRepo.updatePasswordById(userId, encodePassword);
|
|
if (ret == 0) {
|
|
if (ret == 0) {
|