mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
1、移除登录接口可以用验证码登录逻辑,目前直接在登录界面设置密码;2、移除新增的个人密码修改接口;
This commit is contained in:
+1
-10
@@ -30,6 +30,7 @@ public class AuthLoginReqVO {
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "组织名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰科技")
|
||||
@@ -42,10 +43,6 @@ public class AuthLoginReqVO {
|
||||
@NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class)
|
||||
private String captchaVerification;
|
||||
|
||||
@Schema(description = "短信验证码", example = "123456")
|
||||
@Length(min = 6, max = 6, message = "短信验证码长度为 6 位")
|
||||
private String smsCaptchaVerification;
|
||||
|
||||
// ========== 绑定社交登录时,需要传递如下参数 ==========
|
||||
|
||||
@Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@@ -72,10 +69,4 @@ public class AuthLoginReqVO {
|
||||
public boolean isSocialState() {
|
||||
return socialType == null || StringUtils.isNotEmpty(socialState);
|
||||
}
|
||||
|
||||
@AssertTrue(message = "请输入密码后登陆")
|
||||
public boolean isPasswordValid() {
|
||||
// 要么是密码登录、要么是验证码登录
|
||||
return ObjectUtil.isNotNull(password) || ObjectUtil.isNotNull(smsCaptchaVerification);
|
||||
}
|
||||
}
|
||||
|
||||
-19
@@ -1,9 +1,7 @@
|
||||
package com.cf.imes.module.system.controller.admin.user;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
@@ -12,8 +10,6 @@ import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.system.controller.admin.user.vo.user.*;
|
||||
import com.cf.imes.module.system.controller.admin.user.vo.user.UserImportExcelVO;
|
||||
import com.cf.imes.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
||||
@@ -49,13 +45,11 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.PERSONAL_PASSWORD_PERMISSION_ERROR;
|
||||
|
||||
@Tag(name = "管理后台 - 用户")
|
||||
@RestController
|
||||
@@ -107,19 +101,6 @@ public class UserController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update-personal-password")
|
||||
@Operation(summary = "重置用户个人密码")
|
||||
public CommonResult<Boolean> updateUserPersonalPassword(@Valid @RequestBody UserUpdatePasswordReqVO reqVO) {
|
||||
// 校验个人
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (ObjectUtil.isNotNull(loginUser) && Objects.equals(loginUser.getId(), reqVO.getId())) {
|
||||
userService.updateUserPassword(reqVO.getId(), reqVO.getPassword());
|
||||
} else {
|
||||
throw new ServiceException(PERSONAL_PASSWORD_PERMISSION_ERROR);
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/reset-password")
|
||||
@Operation(summary = "忘记密码重置")
|
||||
@PermitAll
|
||||
|
||||
-11
@@ -94,7 +94,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
||||
public AdminUserDO authenticate(AuthLoginReqVO reqVO) {
|
||||
String username = reqVO.getUsername();
|
||||
String password = reqVO.getPassword();
|
||||
String smsCaptchaVerification = reqVO.getSmsCaptchaVerification();
|
||||
final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_USERNAME;
|
||||
// 查询账号
|
||||
AdminUserDO user = userService.getUserUniqueByUserName(username);
|
||||
@@ -116,11 +115,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
||||
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED);
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AUTH_LOGIN_USER_DISABLED);
|
||||
}
|
||||
// 校验没有密码并且没有传验证码,告诉前端需要验证码登录
|
||||
if (StringUtils.isEmpty(userPassword) && StringUtils.isEmpty(smsCaptchaVerification)) {
|
||||
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.FIRST_LOGIN);
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AUTH_LOGIN_FIRST_LOGIN);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -144,11 +138,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
||||
if (StringUtils.isBlank(dataSourceCode)) {
|
||||
throw exception(ORGAN_DATA_CODE_NOT_EXISTS);
|
||||
}
|
||||
// 验证并消耗验证码
|
||||
String smsCaptchaVerification = reqVO.getSmsCaptchaVerification();
|
||||
if (StringUtils.isNotEmpty(smsCaptchaVerification)) {
|
||||
smsCodeService.useSmsCode(SmsCodeUseReqDTO.builder().mobile(user.getUsername()).code(smsCaptchaVerification).scene(SmsSceneEnum.USER_LOGIN_CAPTCHAVERIFICATION.getScene()).build());
|
||||
}
|
||||
// 创建 Token 令牌,记录登录日志
|
||||
return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME,organ.getLarge(), dataSourceCode, user.getOrganId(), user.getNickname());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user