|
@@ -115,7 +115,7 @@ class UserService extends CrudService {
|
|
|
async toBindPhone({ id, phone }) {
|
|
|
const code = _.random(100000, 999999);
|
|
|
const value = `${phone}${this.conenctCode}${code}`;
|
|
|
- await this.redis.set(`${this.bindPhoneKey}${id}`, value, 'EX', 300);
|
|
|
+ await this.redis.set(`${this.bindPhoneKey}${id}`, value); // , 'EX', 300
|
|
|
// 发短信
|
|
|
const data = { config: this.smsServiceConfig, template: 'bind', phone, params: { code } };
|
|
|
const url = `${this.smsServiceUrl}/sendMessage`;
|
|
@@ -128,6 +128,8 @@ class UserService extends CrudService {
|
|
|
const arr = redisData.split(this.conenctCode);
|
|
|
const rphone = _.head(arr);
|
|
|
const rCode = _.last(arr);
|
|
|
+ console.log(rphone, phone);
|
|
|
+ console.log(rCode, code);
|
|
|
if (code !== rCode) throw new BusinessError(ErrorCode.DATA_INVALID, '验证码错误');
|
|
|
if (phone !== rphone) throw new BusinessError(ErrorCode.DATA_INVALID, '要绑定的邮箱与接收验证码的邮箱不是同一个邮箱');
|
|
|
await this.model.updateOne({ _id: id }, { phone });
|