mirror of
https://github.com/certd/certd.git
synced 2026-04-19 00:50:53 +08:00
perf: 增加找回密码的验证码可重试次数 @nicheng-he (#496)
2.找回密码邮件方式增加长度到6位 3.开启自主找回密码放置更合适的位置
This commit is contained in:
@@ -16,6 +16,9 @@ export class SmsCodeReq {
|
||||
|
||||
@Rule(RuleType.string().required().max(4))
|
||||
imgCode: string;
|
||||
|
||||
@Rule(RuleType.string())
|
||||
verificationType: string;
|
||||
}
|
||||
|
||||
export class EmailCodeReq {
|
||||
@@ -32,6 +35,9 @@ export class EmailCodeReq {
|
||||
verificationType: string;
|
||||
}
|
||||
|
||||
// 找回密码的验证码有效期
|
||||
const FORGOT_PASSWORD_CODE_DURATION = 3
|
||||
|
||||
/**
|
||||
*/
|
||||
@Provide()
|
||||
@@ -48,8 +54,18 @@ export class BasicController extends BaseController {
|
||||
@Body(ALL)
|
||||
body: SmsCodeReq
|
||||
) {
|
||||
const opts = {
|
||||
verificationType: body.verificationType,
|
||||
verificationCodeLength: undefined,
|
||||
duration: undefined,
|
||||
};
|
||||
if(body?.verificationType === 'forgotPassword') {
|
||||
opts.duration = FORGOT_PASSWORD_CODE_DURATION;
|
||||
// opts.verificationCodeLength = 6; //部分厂商这里会设置参数长度这里就不改了
|
||||
}
|
||||
|
||||
await this.codeService.checkCaptcha(body.randomStr, body.imgCode);
|
||||
await this.codeService.sendSmsCode(body.phoneCode, body.mobile, body.randomStr);
|
||||
await this.codeService.sendSmsCode(body.phoneCode, body.mobile, body.randomStr, opts);
|
||||
return this.ok(null);
|
||||
}
|
||||
|
||||
@@ -60,6 +76,7 @@ export class BasicController extends BaseController {
|
||||
) {
|
||||
const opts = {
|
||||
verificationType: body.verificationType,
|
||||
verificationCodeLength: undefined,
|
||||
title: undefined,
|
||||
content: undefined,
|
||||
duration: undefined,
|
||||
@@ -67,7 +84,8 @@ export class BasicController extends BaseController {
|
||||
if(body?.verificationType === 'forgotPassword') {
|
||||
opts.title = '找回密码';
|
||||
opts.content = '验证码:${code}。您正在找回密码,请输入验证码并完成操作。如非本人操作请忽略';
|
||||
opts.duration = 3;
|
||||
opts.duration = FORGOT_PASSWORD_CODE_DURATION;
|
||||
opts.verificationCodeLength = 6;
|
||||
}
|
||||
|
||||
await this.codeService.checkCaptcha(body.randomStr, body.imgCode);
|
||||
|
||||
Reference in New Issue
Block a user