fix(系统设置): 用户通过邮箱邀请注册时增加名称长度的校验

--bug=1035151 --user=宋天阳 【系统设置】系统-用户-邮箱邀请用户,邮箱邀请链接页面校验姓名长度提示信息优化 https://www.tapd.cn/55049933/s/1459127
This commit is contained in:
song-tianyang 2024-02-02 11:30:47 +08:00 committed by f2c-ci-robot[bot]
parent a8676365f6
commit b7a3a7348c
4 changed files with 18 additions and 4 deletions

View File

@ -550,8 +550,8 @@ public class FileMetadataService {
fileMetadata.setProjectId(oldFile.getProjectId());
fileMetadata.setModuleId(oldFile.getModuleId());
fileMetadata.setName(oldFile.getName());
fileMetadata.setCreateTime(oldFile.getCreateTime());
fileMetadata.setCreateUser(oldFile.getCreateUser());
fileMetadata.setCreateTime(operationTime);
fileMetadata.setCreateUser(operator);
fileMetadata.setUpdateTime(operationTime);
fileMetadata.setPath(oldFile.getPath());
fileMetadata.setUpdateUser(operator);

View File

@ -2,6 +2,7 @@ package io.metersphere.system.dto.request;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
@Data
@ -12,6 +13,7 @@ public class UserRegisterRequest {
@NotBlank
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
@Size(min = 1, max = 255, message = "{user.name.length_range}")
private String name;
@NotBlank

View File

@ -319,7 +319,7 @@ public class UserLogService {
LogDTO log = LogDTOBuilder.builder()
.projectId(OperationLogConstants.SYSTEM)
.module(OperationLogModule.SETTING_SYSTEM_USER_SINGLE)
.createUser(user.getName())
.createUser(user.getId())
.organizationId(OperationLogConstants.SYSTEM)
.sourceId(user.getId())
.type(OperationLogType.ADD.name())

View File

@ -1351,8 +1351,18 @@ public class UserControllerTests extends BaseTest {
String inviteId = INVITE_RECORD_ID_LIST.getFirst();
UserRegisterRequest request = new UserRegisterRequest();
request.setInviteId(inviteId);
request.setName("建国通过邮箱邀请");
request.setPassword(RsaUtils.publicEncrypt("Cao..12138", RsaUtils.getRsaKey().getPublicKey()));
//先测试反例名称超过255
StringBuilder overSizeName = new StringBuilder();
while (overSizeName.length() < 256) {
overSizeName.append("i");
}
request.setName(overSizeName.toString());
this.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request).andExpect(BAD_REQUEST_MATCHER);
//测试正常创建
request.setName("建国通过邮箱邀请");
MvcResult mvcResult = userRequestUtils.responsePost(UserRequestUtils.URL_INVITE_REGISTER, request);
String resultHolderStr = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(resultHolderStr, ResultHolder.class);
@ -1361,6 +1371,8 @@ public class UserControllerTests extends BaseTest {
LOG_CHECK_LIST.add(
new CheckLogModel(resultHolder.getData().toString(), OperationLogType.ADD, UserRequestUtils.URL_INVITE_REGISTER)
);
}
private void testUserRegisterError() throws Exception {