1、移除登录接口可以用验证码登录逻辑,目前直接在登录界面设置密码;2、移除新增的个人密码修改接口;

This commit is contained in:
gaoqr
2024-09-10 14:35:41 +08:00
parent 2aa4c5e642
commit ebeb8bc5e0
4 changed files with 4 additions and 45 deletions
@@ -16,7 +16,6 @@ public interface ErrorCodeConstants {
ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1_002_000_005, "未绑定账号,需要进行绑定");
ErrorCode AUTH_TOKEN_EXPIRED = new ErrorCode(1_002_000_006, "Token 已经过期");
ErrorCode AUTH_MOBILE_NOT_EXISTS = new ErrorCode(1_002_000_007, "手机号不存在");
ErrorCode AUTH_LOGIN_FIRST_LOGIN = new ErrorCode(1_002_000_008, "请通过验证码登录");
// ========== 菜单模块 1-002-001-000 ==========
ErrorCode MENU_NAME_DUPLICATE = new ErrorCode(1_002_001_000, "已经存在该名字的菜单");
@@ -55,7 +54,6 @@ public interface ErrorCodeConstants {
ErrorCode USERNAME_MULTIPLE_ERROR = new ErrorCode(1_002_003_015,"存在【{}】重复用户,请联系系统管理员");
ErrorCode USER_OPERATE_SELF_STATUS_ERROR = new ErrorCode(1_002_003_016, "不允许操作用户自身状态");
ErrorCode THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_UPPER_LETTER = new ErrorCode(1_002_003_017, "密码必须包含至少一个大写字母");
ErrorCode PERSONAL_PASSWORD_PERMISSION_ERROR = new ErrorCode(1_002_003_018, "修改密码权限不足");
// ========== 部门模块 1-002-004-000 ==========
ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门");
@@ -103,7 +101,7 @@ public interface ErrorCodeConstants {
// ========== 短信发送 1-002-013-000 ==========
ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1_002_013_000, "手机号不存在");
ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_013_001, "模板参数({})缺失");
ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_013_001, "短信模板参数({})缺失");
ErrorCode SMS_SEND_TEMPLATE_NOT_EXISTS = new ErrorCode(1_002_013_002, "短信模板不存在");
// ========== 短信验证码 1-002-014-000 ==========
@@ -178,7 +176,7 @@ public interface ErrorCodeConstants {
ErrorCode MAIL_TEMPLATE_CODE_EXISTS = new ErrorCode(1_002_024_001, "邮件模版 code({}) 已存在");
// ========== 邮件发送 1-002-025-000 ==========
ErrorCode MAIL_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_025_000, "模板参数({})缺失");
ErrorCode MAIL_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_025_000, "邮件模板参数({})缺失");
ErrorCode MAIL_SEND_MAIL_NOT_EXISTS = new ErrorCode(1_002_025_001, "邮箱不存在");
// ========== 站内信模版 1-002-026-000 ==========
@@ -188,7 +186,7 @@ public interface ErrorCodeConstants {
// ========== 站内信模版 1-002-027-000 ==========
// ========== 站内信发送 1-002-028-000 ==========
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "站内信模板参数({})缺失");
//=========== 工序信息 1-002-027-000 ============
@@ -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);
}
}
@@ -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
@@ -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());
}