Skip to content

Commit 4c4597a

Browse files
authored
fix: should use full phone string in database (#746)
1 parent bc59e2a commit 4c4597a

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/v2/services/user/phone.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class UserPhoneService {
4242

4343
if (await UserPhoneService.canSend(safePhone)) {
4444
const exist = await userPhoneDAO.findOne(this.DBTransaction, ["user_uuid"], {
45-
phone_number: safePhone,
45+
phone_number: phone,
4646
});
4747
if (exist) {
4848
throw new FError(ErrorCode.SMSAlreadyExist);
@@ -66,7 +66,7 @@ export class UserPhoneService {
6666

6767
if (await UserPhoneService.canSend(safePhone)) {
6868
const user = await userPhoneDAO.findOne(this.DBTransaction, ["user_uuid"], {
69-
phone_number: safePhone,
69+
phone_number: phone,
7070
});
7171
if (!user) {
7272
throw new FError(ErrorCode.UserNotFound);
@@ -97,7 +97,7 @@ export class UserPhoneService {
9797
await UserPhoneService.assertCodeCorrect(safePhone, code);
9898
await UserPhoneService.clearTryRegisterCount(safePhone);
9999

100-
const userUUIDByPhone = await this.userUUIDByPhone(safePhone);
100+
const userUUIDByPhone = await this.userUUIDByPhone(phone);
101101
if (userUUIDByPhone) {
102102
this.logger.info("register phone already exist", { userPhone: { phone } });
103103
throw new FError(ErrorCode.SMSAlreadyExist);
@@ -116,7 +116,7 @@ export class UserPhoneService {
116116
const createUserPhone = userPhoneDAO.insert(this.DBTransaction, {
117117
user_name: userName,
118118
user_uuid: userUUID,
119-
phone_number: safePhone,
119+
phone_number: phone,
120120
});
121121

122122
const setupGuidePPTX = this.setGuidePPTX(userUUID);
@@ -145,7 +145,7 @@ export class UserPhoneService {
145145
await UserPhoneService.assertCodeCorrect(safePhone, code);
146146
await UserPhoneService.clearTryRegisterCount(safePhone);
147147

148-
const userUUIDByPhone = await this.userUUIDByPhone(safePhone);
148+
const userUUIDByPhone = await this.userUUIDByPhone(phone);
149149
if (!userUUIDByPhone) {
150150
throw new FError(ErrorCode.UserNotFound);
151151
}
@@ -166,9 +166,7 @@ export class UserPhoneService {
166166
): Promise<PhoneLoginReturn> {
167167
password = hash(password);
168168

169-
const safePhone = SMSUtils.safePhone(phone);
170-
171-
const userUUIDByPhone = await this.userUUIDByPhone(safePhone);
169+
const userUUIDByPhone = await this.userUUIDByPhone(phone);
172170
if (!userUUIDByPhone) {
173171
throw new FError(ErrorCode.UserNotFound);
174172
}
@@ -271,9 +269,9 @@ export class UserPhoneService {
271269
]);
272270
}
273271

274-
private async userUUIDByPhone(safePhone: string): Promise<string | null> {
272+
private async userUUIDByPhone(phone: string): Promise<string | null> {
275273
const result = await userPhoneDAO.findOne(this.DBTransaction, ["user_uuid"], {
276-
phone_number: safePhone,
274+
phone_number: phone,
277275
});
278276

279277
return result ? result.user_uuid : null;

src/v2/services/user/rebind-phone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class UserRebindPhoneService {
108108
}
109109

110110
const original = await userPhoneDAO.findOne(this.DBTransaction, ["user_uuid"], {
111-
phone_number: safePhone,
111+
phone_number: phone,
112112
});
113113
if (!original) {
114114
this.logger.info("not found user by phone", { rebindPhone: { phone, safePhone } });

0 commit comments

Comments
 (0)