Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/v2/services/user/phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class UserPhoneService {

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

if (await UserPhoneService.canSend(safePhone)) {
const user = await userPhoneDAO.findOne(this.DBTransaction, ["user_uuid"], {
phone_number: safePhone,
phone_number: phone,
});
if (!user) {
throw new FError(ErrorCode.UserNotFound);
Expand Down Expand Up @@ -97,7 +97,7 @@ export class UserPhoneService {
await UserPhoneService.assertCodeCorrect(safePhone, code);
await UserPhoneService.clearTryRegisterCount(safePhone);

const userUUIDByPhone = await this.userUUIDByPhone(safePhone);
const userUUIDByPhone = await this.userUUIDByPhone(phone);
if (userUUIDByPhone) {
this.logger.info("register phone already exist", { userPhone: { phone } });
throw new FError(ErrorCode.SMSAlreadyExist);
Expand All @@ -116,7 +116,7 @@ export class UserPhoneService {
const createUserPhone = userPhoneDAO.insert(this.DBTransaction, {
user_name: userName,
user_uuid: userUUID,
phone_number: safePhone,
phone_number: phone,
});

const setupGuidePPTX = this.setGuidePPTX(userUUID);
Expand Down Expand Up @@ -145,7 +145,7 @@ export class UserPhoneService {
await UserPhoneService.assertCodeCorrect(safePhone, code);
await UserPhoneService.clearTryRegisterCount(safePhone);

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

const safePhone = SMSUtils.safePhone(phone);

const userUUIDByPhone = await this.userUUIDByPhone(safePhone);
const userUUIDByPhone = await this.userUUIDByPhone(phone);
if (!userUUIDByPhone) {
throw new FError(ErrorCode.UserNotFound);
}
Expand Down Expand Up @@ -271,9 +269,9 @@ export class UserPhoneService {
]);
}

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

return result ? result.user_uuid : null;
Expand Down
2 changes: 1 addition & 1 deletion src/v2/services/user/rebind-phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class UserRebindPhoneService {
}

const original = await userPhoneDAO.findOne(this.DBTransaction, ["user_uuid"], {
phone_number: safePhone,
phone_number: phone,
});
if (!original) {
this.logger.info("not found user by phone", { rebindPhone: { phone, safePhone } });
Expand Down