mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 登录注册、找回密码都支持极验验证码和图片验证码
This commit is contained in:
@@ -36,7 +36,7 @@ export class SysPublicSettings extends BaseSettings {
|
||||
captchaEnabled = false;
|
||||
//验证码类型
|
||||
captchaType?: string;
|
||||
captchaAddonId?:string;
|
||||
captchaAddonId?:number;
|
||||
}
|
||||
|
||||
export class SysPrivateSettings extends BaseSettings {
|
||||
|
||||
@@ -76,9 +76,21 @@ export class AddonService extends BaseService<AddonEntity> {
|
||||
}
|
||||
|
||||
async getAddonById(id: any, checkUserId: boolean, userId?: number): Promise<any> {
|
||||
const ctx = {
|
||||
http: http,
|
||||
logger: logger,
|
||||
utils: utils,
|
||||
};
|
||||
|
||||
|
||||
if (!id){
|
||||
//使用图片验证码
|
||||
return await newAddon("captcha", "image", {},ctx);
|
||||
}
|
||||
const entity = await this.info(id);
|
||||
if (entity == null) {
|
||||
throw new Error(`该Addon配置不存在,请确认是否已被删除:id=${id}`);
|
||||
//使用图片验证码
|
||||
return await newAddon("captcha", "image", {},ctx);
|
||||
}
|
||||
if (checkUserId) {
|
||||
if (userId == null) {
|
||||
@@ -89,17 +101,12 @@ export class AddonService extends BaseService<AddonEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
// const access = accessRegistry.get(entity.type);
|
||||
const setting = JSON.parse(entity.setting ??"{}")
|
||||
const input = {
|
||||
id: entity.id,
|
||||
...setting,
|
||||
};
|
||||
const ctx = {
|
||||
http: http,
|
||||
logger: logger,
|
||||
utils: utils,
|
||||
};
|
||||
|
||||
return await newAddon(entity.addonType, entity.type, input,ctx);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user