diff --git a/shared/consts/consts.ts b/shared/consts/consts.ts index 81e3ad84b..2057fe343 100644 --- a/shared/consts/consts.ts +++ b/shared/consts/consts.ts @@ -103,4 +103,6 @@ export const WAR_JSON_ATTRIBUTE_TYPE = { export const EVENT_QUIZ_NUM = 3; -export const DEFAULT_HEROES = [19, 312, 314, 311, 309, 315]; \ No newline at end of file +export const DEFAULT_HEROES = [19, 312, 314, 311, 309, 315]; + +export const FIX_SMS_CODE_TELS = ['18855953630', '13911134885']; \ No newline at end of file diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index d47a51817..808cb138e 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -1,3 +1,4 @@ +import { FIX_SMS_CODE_TELS } from '@consts/consts'; import { CounterModel } from '@db/Counter'; import { DEFAULT_HEROES } from '@consts/consts'; import { HeroModel } from '@db/Hero'; @@ -63,10 +64,10 @@ export default class Auth extends Service { } let code = ''; - if (!sms || !sms.used) { - code = this.ctx.service.utils.generateNum(6); - } else { + if (sms && (!sms.used || FIX_SMS_CODE_TELS.indexOf(tel) !== -1)) { code = sms.code; + } else { + code = this.ctx.service.utils.generateNum(6); } const smsResult = await this.sendSmsCodeByGuodu(tel, code); @@ -93,11 +94,18 @@ export default class Auth extends Service { if (!_.isString(code) || code.length !== 6) { return ctx.service.utils.resResult(STATUS.WRONG_PARMS); } - - // 手机验证码核验 - const smsValid: boolean = await smsModel.validateSms(tel, code); - if (!smsValid) { - return ctx.service.utils.resResult(STATUS.SMS_INVALID); + // 指定手机号不检查验证码是否使用 + if (FIX_SMS_CODE_TELS.indexOf(tel) === -1) { + // 手机验证码核验 + const smsValid: boolean = await smsModel.validateSms(tel, code); + if (!smsValid) { + return ctx.service.utils.resResult(STATUS.SMS_INVALID); + } + } else { + const sms = await smsModel.findByTel(tel); + if (!sms || sms.code !== code) { + return ctx.service.utils.resResult(STATUS.SMS_INVALID); + } } // 用户注册登录