perf: 验证码支持测试,登录验证码需要测试通过后才能开启

This commit is contained in:
xiaojunnuo
2025-09-26 01:21:01 +08:00
parent 03f317ffdb
commit 83e6476408
18 changed files with 485 additions and 60 deletions
@@ -13,6 +13,8 @@ export class CnameRecordEntity {
@Column({ comment: '证书申请域名', length: 100 })
domain: string;
@Column({ comment: '主域名', name: 'main_domain', length: 100 })
mainDomain:string;
@Column({ comment: '主机记录', name: 'host_record', length: 100 })
hostRecord: string;
@@ -115,6 +115,7 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
hostRecord = hostRecord.substring(0, hostRecord.length - 1);
}
param.hostRecord = hostRecord;
param.mainDomain = realDomain;
const randomKey = utils.id.simpleNanoId(6).toLowerCase();
@@ -191,6 +192,19 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
throw new ValidateException(`找不到${domain}的CNAME记录`);
}
}
if (!record.mainDomain){
let domainPrefix = record.hostRecord.replace("_acme-challenge", "");
if (domainPrefix.startsWith(".")) {
domainPrefix = domainPrefix.substring(1);
}
record.mainDomain = record.domain.replace(domainPrefix, "");
await this.update({
id: record.id,
mainDomain: domainPrefix,
})
}
const provider = await this.cnameProviderService.info(record.cnameProviderId);
if (provider == null) {
throw new ValidateException(`找不到${domain}的CNAME服务`);
@@ -208,7 +222,7 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
* 验证是否配置好cname
* @param id
*/
async verify(id: string) {
async verify(id: number) {
const bean = await this.info(id);
if (!bean) {
throw new ValidateException(`CnameRecord:${id} 不存在`);
@@ -440,4 +454,11 @@ export class CnameRecordService extends BaseService<CnameRecordEntity> {
}
}
async resetStatus (id: number) {
if (!id) {
throw new ValidateException('id不能为空');
}
await this.getRepository().update(id, {status: 'cname',mainDomain: ""});
}
}
@@ -68,10 +68,6 @@ export class TaskServiceGetter implements IServiceGetter{
return new DomainVerifierGetter(this.userId, domainService);
}
}
export type TaskServiceCreateReq = {
userId: number;
}
@Provide()
@Scope(ScopeEnum.Request, { allowDowngrade: true })
export class TaskServiceBuilder {
@@ -84,6 +80,10 @@ export class TaskServiceBuilder {
}
}
export type TaskServiceCreateReq = {
userId: number;
}