Skip to content

Commit 9c205e9

Browse files
authored
Merge pull request #220 from import-ai/fix/username
Fix that the username can be a space
2 parents 2224d22 + a19482c commit 9c205e9

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/i18n/en/user.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"passwordTooShort": "Password must be at least 8 characters long",
88
"passwordRequirements": "Password must contain at least one letter and one number",
99
"emailAlreadyInUse": "Email already in use",
10-
"provideVerificationCode": "Please provide verification code"
10+
"provideVerificationCode": "Please provide verification code",
11+
"userCannotbeEmptyStr": "Invalid username"
1112
}
1213
}

src/i18n/zh/user.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"passwordTooShort": "密码长度至少为 8 个字符",
88
"passwordRequirements": "密码必须包含至少一个字母和一个数字",
99
"emailAlreadyInUse": "邮箱已被使用",
10-
"provideVerificationCode": "请提供邮箱验证码"
10+
"provideVerificationCode": "请提供邮箱验证码",
11+
"userCannotbeEmptyStr": "无效的用户名"
1112
}
1213
}

src/user/user.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ export class UserService {
338338
}
339339

340340
async update(id: string, account: UpdateUserDto) {
341+
if (account.username && !account.username.trim().length) {
342+
const message = this.i18n.t('user.errors.userCannotbeEmptyStr');
343+
throw new AppException(
344+
message,
345+
'USERNAME_CANNOT_BE_EMPTY',
346+
HttpStatus.BAD_REQUEST,
347+
);
348+
}
341349
if (account.username && isUsernameBlocked(account.username)) {
342350
const message = this.i18n.t('user.errors.accountAlreadyExists');
343351
throw new AppException(

0 commit comments

Comments
 (0)