|
@@ -52,10 +52,10 @@ export class LoginService {
|
|
* 注册验证 验证码
|
|
* 注册验证 验证码
|
|
* @param phone 电话号码
|
|
* @param phone 电话号码
|
|
* @param code 验证码
|
|
* @param code 验证码
|
|
- * @returns
|
|
|
|
|
|
+ * @returns
|
|
*/
|
|
*/
|
|
- async checkRegCode(phone,code) {
|
|
|
|
- const redisKey = `${this.regSmsSign}:${phone}`
|
|
|
|
|
|
+ async checkRegCode(phone, code) {
|
|
|
|
+ const redisKey = `${this.regSmsSign}:${phone}`;
|
|
const redisCode = await this.redisService.get(redisKey);
|
|
const redisCode = await this.redisService.get(redisKey);
|
|
if (!redisCode) throw new ServiceError(ErrorCode.REG_VALICODE_EXPIRES); // 验证码已过期
|
|
if (!redisCode) throw new ServiceError(ErrorCode.REG_VALICODE_EXPIRES); // 验证码已过期
|
|
if (`${redisCode}` !== `${code}`) throw new ServiceError(ErrorCode.REG_VALICODE_ERROR); // 验证码错误
|
|
if (`${redisCode}` !== `${code}`) throw new ServiceError(ErrorCode.REG_VALICODE_ERROR); // 验证码错误
|
|
@@ -68,7 +68,7 @@ export class LoginService {
|
|
* @param phone 电话号码
|
|
* @param phone 电话号码
|
|
*/
|
|
*/
|
|
async sendRegCode(phone) {
|
|
async sendRegCode(phone) {
|
|
- const redisKey = `${this.regSmsSign}:${phone}`
|
|
|
|
|
|
+ const redisKey = `${this.regSmsSign}:${phone}`;
|
|
const code = random(1000, 999999);
|
|
const code = random(1000, 999999);
|
|
await this.redisService.set(redisKey, code, 'EX', this.timeLimit);
|
|
await this.redisService.set(redisKey, code, 'EX', this.timeLimit);
|
|
await this.smsService.send(phone, code);
|
|
await this.smsService.send(phone, code);
|