修改密码接口更改
This commit is contained in:
parent
7cbcf3d0f3
commit
4aab90a066
@ -218,6 +218,9 @@ public enum UserErrorCode implements IResponseErrorCode {
|
|||||||
//不在当前团队
|
//不在当前团队
|
||||||
,NOT_IN_TEAM(4073, "Not in team")
|
,NOT_IN_TEAM(4073, "Not in team")
|
||||||
|
|
||||||
|
// 密码不正确
|
||||||
|
,PASSWORD_NOT_MATCH(4074, "password is incorrect")
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -45,12 +45,7 @@ public class AppUserAccountRestController extends BaseController {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改账号密码(账号).
|
* 删除账号密码
|
||||||
*
|
|
||||||
* @eo.name 修改账号密码(账号).
|
|
||||||
* @eo.url /account-pwd-reset
|
|
||||||
* @eo.method post
|
|
||||||
* @eo.request-type json
|
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/account-pwd-reset", consumes = MediaType.APPLICATION_JSON_VALUE)
|
@PostMapping(value = "/account-pwd-reset", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public void accountPwdUpdate(@RequestBody @Validated AccountPwdResetCmd cmd) {
|
public void accountPwdUpdate(@RequestBody @Validated AccountPwdResetCmd cmd) {
|
||||||
|
|||||||
@ -67,12 +67,7 @@ public class UserAuthTypeRestController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号绑定认证关系.
|
* 设置账号密码.
|
||||||
*
|
|
||||||
* @eo.name 账号绑定认证关系.
|
|
||||||
* @eo.url /account-bind
|
|
||||||
* @eo.method post
|
|
||||||
* @eo.request-type json
|
|
||||||
*/
|
*/
|
||||||
@PostMapping("/account-bind")
|
@PostMapping("/account-bind")
|
||||||
public void accountBindUserAuthType(@RequestBody @Validated AccountBindUserAuthTypeCmd cmd) {
|
public void accountBindUserAuthType(@RequestBody @Validated AccountBindUserAuthTypeCmd cmd) {
|
||||||
|
|||||||
@ -1,16 +1,24 @@
|
|||||||
package com.red.circle.other.app.command.user;
|
package com.red.circle.other.app.command.user;
|
||||||
|
|
||||||
|
|
||||||
|
import com.red.circle.component.redis.service.RedisService;
|
||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
|
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||||
import com.red.circle.other.app.dto.cmd.user.user.AccountBindUserAuthTypeCmd;
|
import com.red.circle.other.app.dto.cmd.user.user.AccountBindUserAuthTypeCmd;
|
||||||
import com.red.circle.other.infra.database.rds.entity.user.user.AccountAuth;
|
import com.red.circle.other.infra.database.rds.entity.user.user.AccountAuth;
|
||||||
import com.red.circle.other.infra.database.rds.entity.user.user.AuthType;
|
import com.red.circle.other.infra.database.rds.entity.user.user.AuthType;
|
||||||
|
import com.red.circle.other.infra.database.rds.entity.user.user.PasswordLog;
|
||||||
import com.red.circle.other.infra.database.rds.service.user.user.AccountAuthService;
|
import com.red.circle.other.infra.database.rds.service.user.user.AccountAuthService;
|
||||||
import com.red.circle.other.infra.database.rds.service.user.user.AuthTypeService;
|
import com.red.circle.other.infra.database.rds.service.user.user.AuthTypeService;
|
||||||
|
import com.red.circle.other.infra.database.rds.service.user.user.PasswordLogService;
|
||||||
import com.red.circle.other.inner.asserts.user.UserErrorCode;
|
import com.red.circle.other.inner.asserts.user.UserErrorCode;
|
||||||
import com.red.circle.other.inner.enums.user.AuthTypeEnum;
|
import com.red.circle.other.inner.enums.user.AuthTypeEnum;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -25,31 +33,33 @@ public class AccountBindUserAuthTypeCmdExe {
|
|||||||
|
|
||||||
private final AuthTypeService authTypeService;
|
private final AuthTypeService authTypeService;
|
||||||
private final AccountAuthService accountAuthService;
|
private final AccountAuthService accountAuthService;
|
||||||
|
private final PasswordLogService passwordLogService;
|
||||||
|
|
||||||
public void execute(AccountBindUserAuthTypeCmd cmd) {
|
public void execute(AccountBindUserAuthTypeCmd cmd) {
|
||||||
|
|
||||||
AuthType authType = authTypeService.getAuthInfo(
|
|
||||||
AuthTypeEnum.ACCOUNT.name(),
|
|
||||||
cmd.requiredReqUserIdStr()
|
|
||||||
);
|
|
||||||
|
|
||||||
// 4032 已被绑定
|
|
||||||
ResponseAssert.isNull(UserErrorCode.ALREADY_USED, authType);
|
|
||||||
|
|
||||||
AccountAuth accountAuth = accountAuthService.getByUserId(cmd.requiredReqUserId());
|
|
||||||
|
|
||||||
ResponseAssert.isNull(UserErrorCode.ALREADY_USED, accountAuth);
|
|
||||||
//4061 密码不符合规则
|
//4061 密码不符合规则
|
||||||
ResponseAssert.isTrue(UserErrorCode.ACCOUNT_PASSWORD_NOT_COMPLY_WITH_RULES,
|
ResponseAssert.isTrue(UserErrorCode.ACCOUNT_PASSWORD_NOT_COMPLY_WITH_RULES, validatePassword(cmd.getPwd()));
|
||||||
validatePassword(cmd.getPwd()));
|
|
||||||
|
AccountAuth accountAuth = accountAuthService.getByPassword(cmd.getOldPwd(), cmd.getReqUserId());
|
||||||
|
ResponseAssert.notNull(UserErrorCode.PASSWORD_NOT_MATCH, accountAuth);
|
||||||
|
|
||||||
|
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE, accountAuthService.deleteById(accountAuth.getId()));
|
||||||
|
authTypeService.deleteAuthType(cmd.getReqUserId(), AuthTypeEnum.ACCOUNT.name());
|
||||||
|
|
||||||
accountAuthService.saveAccountAuth(new AccountAuth()
|
accountAuthService.saveAccountAuth(new AccountAuth()
|
||||||
.setUserId(cmd.requiredReqUserId())
|
.setUserId(cmd.requiredReqUserId())
|
||||||
.setPwd(cmd.getPwd())
|
.setPwd(cmd.getPwd())
|
||||||
.setDel(Boolean.FALSE)
|
.setDel(Boolean.FALSE));
|
||||||
);
|
|
||||||
|
|
||||||
authTypeService.save(toAuthType(cmd.requiredReqUserId(), cmd));
|
authTypeService.save(toAuthType(cmd.requiredReqUserId(), cmd));
|
||||||
|
|
||||||
|
passwordLogService.save(PasswordLog.builder()
|
||||||
|
.businessType("ACCOUNT_PASSWORD")
|
||||||
|
.operateType("UPDATE_PASSWORD")
|
||||||
|
.userId(cmd.getReqUserId())
|
||||||
|
.sysOrigin(cmd.requireReqSysOrigin())
|
||||||
|
.pwd(cmd.getPwd())
|
||||||
|
.imei(cmd.getReqImei())
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,4 +23,9 @@ public class AccountBindUserAuthTypeCmd extends AppExtCommand {
|
|||||||
@NotBlank(message = "pwd required.")
|
@NotBlank(message = "pwd required.")
|
||||||
private String pwd;
|
private String pwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 旧密码
|
||||||
|
*/
|
||||||
|
private String oldPwd;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user