diff --git a/es/aspects/token.js b/es/aspects/token.js
index 6571114d0..4dbd00063 100644
--- a/es/aspects/token.js
+++ b/es/aspects/token.js
@@ -11,6 +11,7 @@ import { mergeUser } from './user';
import { cloneDeep } from 'oak-domain/lib/utils/lodash';
import { sendEmail } from '../utils/email';
import { isEmail, isMobile } from 'oak-domain/lib/utils/validator';
+import { getAndCheckPassportByEmail } from '../utils/passport';
async function makeDistinguishException(userId, context, message) {
const [user] = await context.select('user', {
data: {
@@ -468,6 +469,16 @@ export async function loginByMobile(params, context) {
if (captchaRow.expired) {
throw new OakUserException('验证码已经过期');
}
+ await context.operate('captcha', {
+ id: await generateNewIdAsync(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captchaRow.id
+ }
+ }, {});
// 到这里说明验证码已经通过
return await setupMobile(mobile, env, context);
}
@@ -560,49 +571,7 @@ export async function loginByAccount(params, context) {
assert(account);
const accountType = isEmail(account) ? 'email' : (isMobile(account) ? 'mobile' : 'loginName');
if (accountType === 'email') {
- // const application = context.getApplication();
- // const { system } = application!;
- // const [applicationPassport] = await context.select('applicationPassport',
- // {
- // data: {
- // id: 1,
- // passportId: 1,
- // passport: {
- // id: 1,
- // config: 1,
- // type: 1,
- // },
- // applicationId: 1,
- // },
- // filter: {
- // applicationId: application?.id!,
- // passport: {
- // type: 'email'
- // },
- // }
- // },
- // {
- // dontCollect: true,
- // }
- // );
- // assert(applicationPassport?.passport);
- // const config = applicationPassport.passport.config as EmailConfig;
- // const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- // assert(emailConfig);
- // const emailSuffixes = config.emailSuffixes;
- // // 检查邮箱后缀是否满足配置
- // if (emailSuffixes?.length! > 0) {
- // let isValid = false;
- // for (const suffix of emailSuffixes!) {
- // if (account.endsWith(suffix)) {
- // isValid = true;
- // break;
- // }
- // }
- // if (!isValid) {
- // throw new OakUserException('error::user.emailSuffixIsInvalid');
- // }
- // }
+ const { config, emailConfig } = await getAndCheckPassportByEmail(context, account);
const existEmail = await context.select('email', {
data: {
id: 1,
@@ -980,46 +949,7 @@ export async function loginByEmail(params, context) {
}
};
const closeRootMode = context.openRootMode();
- const application = context.getApplication();
- const { system } = application;
- const [applicationPassport] = await context.select('applicationPassport', {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id,
- passport: {
- type: 'email'
- },
- }
- }, {
- dontCollect: true,
- });
- assert(applicationPassport?.passport);
- const config = applicationPassport.passport.config;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- assert(emailConfig);
- const emailSuffixes = config.emailSuffixes;
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
- if (!isValid) {
- throw new OakUserException('邮箱后缀不符合要求');
- }
- }
+ const { config, emailConfig } = await getAndCheckPassportByEmail(context, email);
if (disableRegister) {
const [existEmail] = await context.select('email', {
data: {
@@ -1073,6 +1003,16 @@ export async function bindByMobile(params, context) {
throw new OakUserException('验证码已经过期');
}
// 到这里说明验证码已经通过
+ await context.operate('captcha', {
+ id: await generateNewIdAsync(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captchaRow.id
+ }
+ }, {});
// 检查当前user是否已绑定mobile
const [boundMobile] = await context.select('mobile', {
data: {
@@ -1233,46 +1173,7 @@ export async function bindByEmail(params, context) {
}
};
const closeRootMode = context.openRootMode();
- const application = context.getApplication();
- const { system } = application;
- const [applicationPassport] = await context.select('applicationPassport', {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id,
- passport: {
- type: 'email'
- },
- }
- }, {
- dontCollect: true,
- });
- assert(applicationPassport?.passport);
- const config = applicationPassport.passport.config;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- assert(emailConfig);
- const emailSuffixes = config.emailSuffixes;
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
- if (!isValid) {
- throw new OakUserException('邮箱后缀不符合要求');
- }
- }
+ const { config, emailConfig } = await getAndCheckPassportByEmail(context, email);
const [otherUserEmail] = await context.select('email', {
data: {
id: 1,
@@ -2054,6 +1955,7 @@ export async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, c
const [count1, count2] = await Promise.all([
context.count('captcha', {
filter: {
+ origin: 'mobile',
visitorId,
$$createAt$$: {
$gt: now - 3600 * 1000,
@@ -2105,10 +2007,11 @@ export async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, c
code = mobile.substring(11 - digit);
}
else {
- code = Math.floor(Math.random() * Math.pow(10, digit)).toString();
- while (code.length < digit) {
- code += '0';
- }
+ // code = Math.floor(Math.random() * Math.pow(10, digit)).toString();
+ // while (code.length < digit) {
+ // code += '0';
+ // }
+ code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join('');
}
const id = await generateNewIdAsync();
await context.operate('captcha', {
@@ -2137,6 +2040,17 @@ export async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, c
closeRootMode();
throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
}
+ await context.operate('captcha', {
+ id: await generateNewIdAsync(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captcha.id
+ }
+ }, {});
+ code = await getCode();
}
else {
code = await getCode();
@@ -2168,49 +2082,10 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con
if (type === 'web' || type === 'native') {
visitorId = env.visitorId;
}
- const application = context.getApplication();
- const { system } = application;
- const [applicationPassport] = await context.select('applicationPassport', {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id,
- passport: {
- type: 'email'
- },
- }
- }, {
- dontCollect: true,
- });
- assert(applicationPassport?.passport);
- const config = applicationPassport.passport.config;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- assert(emailConfig);
+ const { config, emailConfig } = await getAndCheckPassportByEmail(context, email);
const duration = config.codeDuration || 5;
const digit = config.digit || 4;
const mockSend = config.mockSend;
- const emailSuffixes = config.emailSuffixes;
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
- if (!isValid) {
- throw new OakUserException('邮箱后缀不符合要求');
- }
- }
let emailOptions = {
// host: emailConfig.host,
// port: emailConfig.port,
@@ -2229,6 +2104,7 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con
const [count1, count2] = await Promise.all([
context.count('captcha', {
filter: {
+ origin: 'email',
visitorId,
$$createAt$$: {
$gt: now - 3600 * 1000,
@@ -2276,10 +2152,11 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con
});
const getCode = async () => {
let code;
- code = Math.floor(Math.random() * Math.random() * Math.pow(10, digit)).toString();
- while (code.length < digit) {
- code += '0';
- }
+ // code = Math.floor(Math.random() * Math.random() * Math.pow(10, digit)).toString();
+ // while (code.length < digit) {
+ // code += '0';
+ // }
+ code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join('');
const id = await generateNewIdAsync();
await context.operate('captcha', {
id: await generateNewIdAsync(),
@@ -2307,6 +2184,17 @@ export async function sendCaptchaByEmail({ email, env, type: captchaType, }, con
closeRootMode();
throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
}
+ await context.operate('captcha', {
+ id: await generateNewIdAsync(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captcha.id
+ }
+ }, {});
+ code = await getCode();
}
else {
code = await getCode();
diff --git a/es/components/config/application/web/index.js b/es/components/config/application/web/index.js
index d8b39a720..5365d6a6e 100644
--- a/es/components/config/application/web/index.js
+++ b/es/components/config/application/web/index.js
@@ -35,6 +35,24 @@ export default function Web(props) {
+
+
+ 网站-微信支付
+
+
+ <>
+ setValue(`wechatPay.appId`, e.target.value)}/>
+ >
+
+
+ <>
+ setValue(`wechatPay.appSecret`, e.target.value)}/>
+ >
+
+
+
+
location
@@ -68,61 +86,5 @@ export default function Web(props) {
-
- {/*
-
- 网站-授权方式
-
-
- <>
-
-
- */}
);
}
diff --git a/es/components/config/application/wechatPublic/index.js b/es/components/config/application/wechatPublic/index.js
index f19fee2d6..cb314970b 100644
--- a/es/components/config/application/wechatPublic/index.js
+++ b/es/components/config/application/wechatPublic/index.js
@@ -5,7 +5,6 @@ export default function WechatPublic(props) {
const [open, setModal] = useState(false);
const [messageType, setMessageType] = useState('');
const { config, setValue, cleanKey, removeItem, isService = true } = props;
- const templateMsgs = config?.templateMsgs || {};
return (
diff --git a/es/components/config/style/platform/index.d.ts b/es/components/config/style/platform/index.d.ts
index 8835a6c5f..9224d2cdc 100644
--- a/es/components/config/style/platform/index.d.ts
+++ b/es/components/config/style/platform/index.d.ts
@@ -1,7 +1,7 @@
import { Style } from '../../../../types/Style';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement;
diff --git a/es/components/extraFile/commit/index.d.ts b/es/components/extraFile/commit/index.d.ts
index 2b5d47f16..3142f4db7 100644
--- a/es/components/extraFile/commit/index.d.ts
+++ b/es/components/extraFile/commit/index.d.ts
@@ -24,7 +24,7 @@ declare const _default: ) => unknown) | undefined;
- type?: "button" | "submit" | "reset" | undefined;
+ type?: "button" | "reset" | "submit" | undefined;
shape?: "default" | "rounded" | "rectangular" | undefined;
children?: import("react").ReactNode;
} & Pick & import("react").ButtonHTMLAttributes, "id" | "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
diff --git a/es/components/wechatLogin/qrCode/index.d.ts b/es/components/wechatLogin/qrCode/index.d.ts
index db7fcdc9b..21f928111 100644
--- a/es/components/wechatLogin/qrCode/index.d.ts
+++ b/es/components/wechatLogin/qrCode/index.d.ts
@@ -1,6 +1,6 @@
import { EntityDict } from '../../../oak-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement;
diff --git a/es/entities/Application.d.ts b/es/entities/Application.d.ts
index 7640b7f0c..014ca473f 100644
--- a/es/entities/Application.d.ts
+++ b/es/entities/Application.d.ts
@@ -29,6 +29,10 @@ export type WebConfig = {
domain?: string;
enable?: boolean;
};
+ wechatPay?: {
+ appId: string;
+ appSecret: string;
+ };
passport?: Passport[];
location: {
protocol: 'http:' | 'https:';
@@ -36,14 +40,12 @@ export type WebConfig = {
port: string;
};
};
-export type WechatPublicTemplateMsgsConfig = Record;
export type WechatPublicConfig = {
type: 'wechatPublic';
isService: boolean;
appId: string;
appSecret: string;
originalId?: string;
- templateMsgs?: WechatPublicTemplateMsgsConfig;
server?: {
url?: string;
token: string;
diff --git a/es/oak-app-domain/Application/_baseSchema.d.ts b/es/oak-app-domain/Application/_baseSchema.d.ts
index e7322f731..7070996bc 100644
--- a/es/oak-app-domain/Application/_baseSchema.d.ts
+++ b/es/oak-app-domain/Application/_baseSchema.d.ts
@@ -29,6 +29,10 @@ export type WebConfig = {
domain?: string;
enable?: boolean;
};
+ wechatPay?: {
+ appId: string;
+ appSecret: string;
+ };
passport?: Passport[];
location: {
protocol: "http:" | "https:";
@@ -36,14 +40,12 @@ export type WebConfig = {
port: string;
};
};
-export type WechatPublicTemplateMsgsConfig = Record;
export type WechatPublicConfig = {
type: "wechatPublic";
isService: boolean;
appId: string;
appSecret: string;
originalId?: string;
- templateMsgs?: WechatPublicTemplateMsgsConfig;
server?: {
url?: string;
token: string;
diff --git a/es/triggers/index.d.ts b/es/triggers/index.d.ts
index fa5f310b6..54d1ce8ac 100644
--- a/es/triggers/index.d.ts
+++ b/es/triggers/index.d.ts
@@ -1,2 +1,2 @@
-declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[];
+declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[];
export default _default;
diff --git a/es/triggers/toDo.d.ts b/es/triggers/toDo.d.ts
index 1d9bc2ce2..e5be399e1 100644
--- a/es/triggers/toDo.d.ts
+++ b/es/triggers/toDo.d.ts
@@ -14,7 +14,7 @@ export declare function createToDo;
+}, userIds?: string[]): Promise<1 | 0>;
/**
* 完成todo例程,当在entity对象上进行action操作时(操作条件是filter),将对应的todo完成
* 必须在entity的action的后trigger中调用
diff --git a/es/types/Config.d.ts b/es/types/Config.d.ts
index 2c01bb85a..27761ea37 100644
--- a/es/types/Config.d.ts
+++ b/es/types/Config.d.ts
@@ -9,10 +9,10 @@ export type QiniuLiveConfig = {
liveHost: string;
hub: string;
publishDomain: string;
- playDomainType: 'rtmp' | 'hls' | 'flv';
+ playDomainType?: 'rtmp' | 'hls' | 'flv';
playDomain: string;
playBackDomain: string;
- publishSecurity: 'none' | 'static' | 'expiry' | 'expiry_sk';
+ publishSecurity?: 'none' | 'static' | 'expiry' | 'expiry_sk';
publishKey: string;
playKey: string;
};
diff --git a/es/utils/passport.d.ts b/es/utils/passport.d.ts
new file mode 100644
index 000000000..e0982ae8f
--- /dev/null
+++ b/es/utils/passport.d.ts
@@ -0,0 +1,7 @@
+import { EntityDict } from "../oak-app-domain";
+import { BRC } from "../types/RuntimeCxt";
+import { EmailConfig } from '../oak-app-domain/Passport/Schema';
+export declare function getAndCheckPassportByEmail(context: BRC, email: string): Promise<{
+ emailConfig: import("../types/Config").EmailConfig;
+ config: EmailConfig;
+}>;
diff --git a/es/utils/passport.js b/es/utils/passport.js
new file mode 100644
index 000000000..600f9d428
--- /dev/null
+++ b/es/utils/passport.js
@@ -0,0 +1,48 @@
+import { assert } from 'oak-domain/lib/utils/assert';
+import { OakUserException } from 'oak-domain/lib/types';
+export async function getAndCheckPassportByEmail(context, email) {
+ const application = context.getApplication();
+ const { system } = application;
+ const [applicationPassport] = await context.select('applicationPassport', {
+ data: {
+ id: 1,
+ passportId: 1,
+ passport: {
+ id: 1,
+ config: 1,
+ type: 1,
+ },
+ applicationId: 1,
+ },
+ filter: {
+ applicationId: application?.id,
+ passport: {
+ type: 'email',
+ },
+ },
+ }, {
+ dontCollect: true,
+ });
+ assert(applicationPassport?.passport);
+ const config = applicationPassport.passport.config;
+ const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
+ assert(emailConfig);
+ const emailSuffixes = config.emailSuffixes;
+ // 检查邮箱后缀是否满足配置
+ if (emailSuffixes?.length > 0) {
+ let isValid = false;
+ for (const suffix of emailSuffixes) {
+ if (email.endsWith(suffix)) {
+ isValid = true;
+ break;
+ }
+ }
+ if (!isValid) {
+ throw new OakUserException('error::user.emailSuffixIsInvalid');
+ }
+ }
+ return {
+ emailConfig,
+ config
+ };
+}
diff --git a/lib/aspects/token.js b/lib/aspects/token.js
index 8a05143e5..4ff16bfe6 100644
--- a/lib/aspects/token.js
+++ b/lib/aspects/token.js
@@ -15,6 +15,7 @@ const user_1 = require("./user");
const lodash_1 = require("oak-domain/lib/utils/lodash");
const email_1 = require("../utils/email");
const validator_1 = require("oak-domain/lib/utils/validator");
+const passport_1 = require("../utils/passport");
async function makeDistinguishException(userId, context, message) {
const [user] = await context.select('user', {
data: {
@@ -472,6 +473,16 @@ async function loginByMobile(params, context) {
if (captchaRow.expired) {
throw new types_1.OakUserException('验证码已经过期');
}
+ await context.operate('captcha', {
+ id: await (0, uuid_1.generateNewIdAsync)(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captchaRow.id
+ }
+ }, {});
// 到这里说明验证码已经通过
return await setupMobile(mobile, env, context);
}
@@ -566,49 +577,7 @@ async function loginByAccount(params, context) {
(0, assert_1.assert)(account);
const accountType = (0, validator_1.isEmail)(account) ? 'email' : ((0, validator_1.isMobile)(account) ? 'mobile' : 'loginName');
if (accountType === 'email') {
- // const application = context.getApplication();
- // const { system } = application!;
- // const [applicationPassport] = await context.select('applicationPassport',
- // {
- // data: {
- // id: 1,
- // passportId: 1,
- // passport: {
- // id: 1,
- // config: 1,
- // type: 1,
- // },
- // applicationId: 1,
- // },
- // filter: {
- // applicationId: application?.id!,
- // passport: {
- // type: 'email'
- // },
- // }
- // },
- // {
- // dontCollect: true,
- // }
- // );
- // assert(applicationPassport?.passport);
- // const config = applicationPassport.passport.config as EmailConfig;
- // const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- // assert(emailConfig);
- // const emailSuffixes = config.emailSuffixes;
- // // 检查邮箱后缀是否满足配置
- // if (emailSuffixes?.length! > 0) {
- // let isValid = false;
- // for (const suffix of emailSuffixes!) {
- // if (account.endsWith(suffix)) {
- // isValid = true;
- // break;
- // }
- // }
- // if (!isValid) {
- // throw new OakUserException('error::user.emailSuffixIsInvalid');
- // }
- // }
+ const { config, emailConfig } = await (0, passport_1.getAndCheckPassportByEmail)(context, account);
const existEmail = await context.select('email', {
data: {
id: 1,
@@ -987,46 +956,7 @@ async function loginByEmail(params, context) {
}
};
const closeRootMode = context.openRootMode();
- const application = context.getApplication();
- const { system } = application;
- const [applicationPassport] = await context.select('applicationPassport', {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id,
- passport: {
- type: 'email'
- },
- }
- }, {
- dontCollect: true,
- });
- (0, assert_1.assert)(applicationPassport?.passport);
- const config = applicationPassport.passport.config;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- (0, assert_1.assert)(emailConfig);
- const emailSuffixes = config.emailSuffixes;
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
- if (!isValid) {
- throw new types_1.OakUserException('邮箱后缀不符合要求');
- }
- }
+ const { config, emailConfig } = await (0, passport_1.getAndCheckPassportByEmail)(context, email);
if (disableRegister) {
const [existEmail] = await context.select('email', {
data: {
@@ -1081,6 +1011,16 @@ async function bindByMobile(params, context) {
throw new types_1.OakUserException('验证码已经过期');
}
// 到这里说明验证码已经通过
+ await context.operate('captcha', {
+ id: await (0, uuid_1.generateNewIdAsync)(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captchaRow.id
+ }
+ }, {});
// 检查当前user是否已绑定mobile
const [boundMobile] = await context.select('mobile', {
data: {
@@ -1242,46 +1182,7 @@ async function bindByEmail(params, context) {
}
};
const closeRootMode = context.openRootMode();
- const application = context.getApplication();
- const { system } = application;
- const [applicationPassport] = await context.select('applicationPassport', {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id,
- passport: {
- type: 'email'
- },
- }
- }, {
- dontCollect: true,
- });
- (0, assert_1.assert)(applicationPassport?.passport);
- const config = applicationPassport.passport.config;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- (0, assert_1.assert)(emailConfig);
- const emailSuffixes = config.emailSuffixes;
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
- if (!isValid) {
- throw new types_1.OakUserException('邮箱后缀不符合要求');
- }
- }
+ const { config, emailConfig } = await (0, passport_1.getAndCheckPassportByEmail)(context, email);
const [otherUserEmail] = await context.select('email', {
data: {
id: 1,
@@ -2070,6 +1971,7 @@ async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context)
const [count1, count2] = await Promise.all([
context.count('captcha', {
filter: {
+ origin: 'mobile',
visitorId,
$$createAt$$: {
$gt: now - 3600 * 1000,
@@ -2121,10 +2023,11 @@ async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context)
code = mobile.substring(11 - digit);
}
else {
- code = Math.floor(Math.random() * Math.pow(10, digit)).toString();
- while (code.length < digit) {
- code += '0';
- }
+ // code = Math.floor(Math.random() * Math.pow(10, digit)).toString();
+ // while (code.length < digit) {
+ // code += '0';
+ // }
+ code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join('');
}
const id = await (0, uuid_1.generateNewIdAsync)();
await context.operate('captcha', {
@@ -2153,6 +2056,17 @@ async function sendCaptchaByMobile({ mobile, env, type: captchaType, }, context)
closeRootMode();
throw new types_1.OakUserException('您的操作太迅捷啦,请稍候再点吧');
}
+ await context.operate('captcha', {
+ id: await (0, uuid_1.generateNewIdAsync)(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captcha.id
+ }
+ }, {});
+ code = await getCode();
}
else {
code = await getCode();
@@ -2185,49 +2099,10 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) {
if (type === 'web' || type === 'native') {
visitorId = env.visitorId;
}
- const application = context.getApplication();
- const { system } = application;
- const [applicationPassport] = await context.select('applicationPassport', {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id,
- passport: {
- type: 'email'
- },
- }
- }, {
- dontCollect: true,
- });
- (0, assert_1.assert)(applicationPassport?.passport);
- const config = applicationPassport.passport.config;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- (0, assert_1.assert)(emailConfig);
+ const { config, emailConfig } = await (0, passport_1.getAndCheckPassportByEmail)(context, email);
const duration = config.codeDuration || 5;
const digit = config.digit || 4;
const mockSend = config.mockSend;
- const emailSuffixes = config.emailSuffixes;
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
- if (!isValid) {
- throw new types_1.OakUserException('邮箱后缀不符合要求');
- }
- }
let emailOptions = {
// host: emailConfig.host,
// port: emailConfig.port,
@@ -2246,6 +2121,7 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) {
const [count1, count2] = await Promise.all([
context.count('captcha', {
filter: {
+ origin: 'email',
visitorId,
$$createAt$$: {
$gt: now - 3600 * 1000,
@@ -2293,10 +2169,11 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) {
});
const getCode = async () => {
let code;
- code = Math.floor(Math.random() * Math.random() * Math.pow(10, digit)).toString();
- while (code.length < digit) {
- code += '0';
- }
+ // code = Math.floor(Math.random() * Math.random() * Math.pow(10, digit)).toString();
+ // while (code.length < digit) {
+ // code += '0';
+ // }
+ code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join('');
const id = await (0, uuid_1.generateNewIdAsync)();
await context.operate('captcha', {
id: await (0, uuid_1.generateNewIdAsync)(),
@@ -2324,6 +2201,17 @@ async function sendCaptchaByEmail({ email, env, type: captchaType, }, context) {
closeRootMode();
throw new types_1.OakUserException('您的操作太迅捷啦,请稍候再点吧');
}
+ await context.operate('captcha', {
+ id: await (0, uuid_1.generateNewIdAsync)(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captcha.id
+ }
+ }, {});
+ code = await getCode();
}
else {
code = await getCode();
diff --git a/lib/entities/Application.d.ts b/lib/entities/Application.d.ts
index 7640b7f0c..014ca473f 100644
--- a/lib/entities/Application.d.ts
+++ b/lib/entities/Application.d.ts
@@ -29,6 +29,10 @@ export type WebConfig = {
domain?: string;
enable?: boolean;
};
+ wechatPay?: {
+ appId: string;
+ appSecret: string;
+ };
passport?: Passport[];
location: {
protocol: 'http:' | 'https:';
@@ -36,14 +40,12 @@ export type WebConfig = {
port: string;
};
};
-export type WechatPublicTemplateMsgsConfig = Record;
export type WechatPublicConfig = {
type: 'wechatPublic';
isService: boolean;
appId: string;
appSecret: string;
originalId?: string;
- templateMsgs?: WechatPublicTemplateMsgsConfig;
server?: {
url?: string;
token: string;
diff --git a/lib/oak-app-domain/Application/_baseSchema.d.ts b/lib/oak-app-domain/Application/_baseSchema.d.ts
index e7322f731..7070996bc 100644
--- a/lib/oak-app-domain/Application/_baseSchema.d.ts
+++ b/lib/oak-app-domain/Application/_baseSchema.d.ts
@@ -29,6 +29,10 @@ export type WebConfig = {
domain?: string;
enable?: boolean;
};
+ wechatPay?: {
+ appId: string;
+ appSecret: string;
+ };
passport?: Passport[];
location: {
protocol: "http:" | "https:";
@@ -36,14 +40,12 @@ export type WebConfig = {
port: string;
};
};
-export type WechatPublicTemplateMsgsConfig = Record;
export type WechatPublicConfig = {
type: "wechatPublic";
isService: boolean;
appId: string;
appSecret: string;
originalId?: string;
- templateMsgs?: WechatPublicTemplateMsgsConfig;
server?: {
url?: string;
token: string;
diff --git a/lib/triggers/index.d.ts b/lib/triggers/index.d.ts
index fa5f310b6..54d1ce8ac 100644
--- a/lib/triggers/index.d.ts
+++ b/lib/triggers/index.d.ts
@@ -1,2 +1,2 @@
-declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[];
+declare const _default: (import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger> | import("oak-domain/lib/types").Trigger>)[];
export default _default;
diff --git a/lib/types/Config.d.ts b/lib/types/Config.d.ts
index 2c01bb85a..27761ea37 100644
--- a/lib/types/Config.d.ts
+++ b/lib/types/Config.d.ts
@@ -9,10 +9,10 @@ export type QiniuLiveConfig = {
liveHost: string;
hub: string;
publishDomain: string;
- playDomainType: 'rtmp' | 'hls' | 'flv';
+ playDomainType?: 'rtmp' | 'hls' | 'flv';
playDomain: string;
playBackDomain: string;
- publishSecurity: 'none' | 'static' | 'expiry' | 'expiry_sk';
+ publishSecurity?: 'none' | 'static' | 'expiry' | 'expiry_sk';
publishKey: string;
playKey: string;
};
diff --git a/lib/utils/passport.d.ts b/lib/utils/passport.d.ts
new file mode 100644
index 000000000..e0982ae8f
--- /dev/null
+++ b/lib/utils/passport.d.ts
@@ -0,0 +1,7 @@
+import { EntityDict } from "../oak-app-domain";
+import { BRC } from "../types/RuntimeCxt";
+import { EmailConfig } from '../oak-app-domain/Passport/Schema';
+export declare function getAndCheckPassportByEmail(context: BRC, email: string): Promise<{
+ emailConfig: import("../types/Config").EmailConfig;
+ config: EmailConfig;
+}>;
diff --git a/lib/utils/passport.js b/lib/utils/passport.js
new file mode 100644
index 000000000..8c58265ac
--- /dev/null
+++ b/lib/utils/passport.js
@@ -0,0 +1,52 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getAndCheckPassportByEmail = void 0;
+const assert_1 = require("oak-domain/lib/utils/assert");
+const types_1 = require("oak-domain/lib/types");
+async function getAndCheckPassportByEmail(context, email) {
+ const application = context.getApplication();
+ const { system } = application;
+ const [applicationPassport] = await context.select('applicationPassport', {
+ data: {
+ id: 1,
+ passportId: 1,
+ passport: {
+ id: 1,
+ config: 1,
+ type: 1,
+ },
+ applicationId: 1,
+ },
+ filter: {
+ applicationId: application?.id,
+ passport: {
+ type: 'email',
+ },
+ },
+ }, {
+ dontCollect: true,
+ });
+ (0, assert_1.assert)(applicationPassport?.passport);
+ const config = applicationPassport.passport.config;
+ const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
+ (0, assert_1.assert)(emailConfig);
+ const emailSuffixes = config.emailSuffixes;
+ // 检查邮箱后缀是否满足配置
+ if (emailSuffixes?.length > 0) {
+ let isValid = false;
+ for (const suffix of emailSuffixes) {
+ if (email.endsWith(suffix)) {
+ isValid = true;
+ break;
+ }
+ }
+ if (!isValid) {
+ throw new types_1.OakUserException('error::user.emailSuffixIsInvalid');
+ }
+ }
+ return {
+ emailConfig,
+ config
+ };
+}
+exports.getAndCheckPassportByEmail = getAndCheckPassportByEmail;
diff --git a/src/aspects/token.ts b/src/aspects/token.ts
index cef139478..4b0894265 100644
--- a/src/aspects/token.ts
+++ b/src/aspects/token.ts
@@ -44,6 +44,7 @@ import { sendEmail } from '../utils/email';
import { EmailConfig } from '../oak-app-domain/Passport/Schema';
import { isEmail, isMobile } from 'oak-domain/lib/utils/validator';
import { EmailOptions } from '../types/Email';
+import { getAndCheckPassportByEmail } from '../utils/passport';
async function makeDistinguishException(userId: string, context: BRC, message?: string) {
const [user] = await context.select(
@@ -641,6 +642,20 @@ export async function loginByMobile(
if (captchaRow.expired) {
throw new OakUserException('验证码已经过期');
}
+ await context.operate(
+ 'captcha',
+ {
+ id: await generateNewIdAsync(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captchaRow.id!
+ }
+ },
+ {}
+ );
// 到这里说明验证码已经通过
return await setupMobile(mobile, env, context);
@@ -762,50 +777,9 @@ export async function loginByAccount(
assert(account);
const accountType = isEmail(account) ? 'email' : (isMobile(account) ? 'mobile' : 'loginName');
if (accountType === 'email') {
- // const application = context.getApplication();
- // const { system } = application!;
- // const [applicationPassport] = await context.select('applicationPassport',
- // {
- // data: {
- // id: 1,
- // passportId: 1,
- // passport: {
- // id: 1,
- // config: 1,
- // type: 1,
- // },
- // applicationId: 1,
- // },
- // filter: {
- // applicationId: application?.id!,
- // passport: {
- // type: 'email'
- // },
- // }
- // },
- // {
- // dontCollect: true,
- // }
- // );
- // assert(applicationPassport?.passport);
- // const config = applicationPassport.passport.config as EmailConfig;
- // const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- // assert(emailConfig);
- // const emailSuffixes = config.emailSuffixes;
-
- // // 检查邮箱后缀是否满足配置
- // if (emailSuffixes?.length! > 0) {
- // let isValid = false;
- // for (const suffix of emailSuffixes!) {
- // if (account.endsWith(suffix)) {
- // isValid = true;
- // break;
- // }
- // }
- // if (!isValid) {
- // throw new OakUserException('error::user.emailSuffixIsInvalid');
- // }
- // }
+
+ const { config, emailConfig } = await getAndCheckPassportByEmail(context, account);
+
const existEmail = await context.select(
'email',
{
@@ -1244,51 +1218,9 @@ export async function loginByEmail(
}
};
const closeRootMode = context.openRootMode();
- const application = context.getApplication();
- const { system } = application!;
- const [applicationPassport] = await context.select('applicationPassport',
- {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id!,
- passport: {
- type: 'email'
- },
- }
- },
- {
- dontCollect: true,
- }
- );
- assert(applicationPassport?.passport);
- const config = applicationPassport.passport.config as EmailConfig;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- assert(emailConfig);
- const emailSuffixes = config.emailSuffixes;
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length! > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes!) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
+ const { config, emailConfig } = await getAndCheckPassportByEmail(context, email);
- if (!isValid) {
- throw new OakUserException('邮箱后缀不符合要求')
- }
- }
if (disableRegister) {
const [existEmail] = await context.select(
'email',
@@ -1359,8 +1291,22 @@ export async function bindByMobile(
if (captchaRow.expired) {
throw new OakUserException('验证码已经过期');
}
-
// 到这里说明验证码已经通过
+ await context.operate(
+ 'captcha',
+ {
+ id: await generateNewIdAsync(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captchaRow.id!
+ }
+ },
+ {}
+ );
+
// 检查当前user是否已绑定mobile
const [boundMobile] = await context.select(
'mobile',
@@ -1379,6 +1325,7 @@ export async function bindByMobile(
forUpdate: true,
}
)
+
if (boundMobile) {
//用户已绑定的mobile与当前输入的mobile一致
if (boundMobile.mobile === mobile) {
@@ -1567,51 +1514,8 @@ export async function bindByEmail(
const closeRootMode = context.openRootMode();
- const application = context.getApplication();
- const { system } = application!;
- const [applicationPassport] = await context.select('applicationPassport',
- {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id!,
- passport: {
- type: 'email'
- },
- }
- },
- {
- dontCollect: true,
- }
- );
- assert(applicationPassport?.passport);
- const config = applicationPassport.passport.config as EmailConfig;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- assert(emailConfig);
- const emailSuffixes = config.emailSuffixes;
+ const { config, emailConfig } = await getAndCheckPassportByEmail(context, email);
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length! > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes!) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
-
- if (!isValid) {
- throw new OakUserException('邮箱后缀不符合要求')
- }
- }
const [otherUserEmail] = await context.select(
'email',
@@ -2730,6 +2634,7 @@ export async function sendCaptchaByMobile(
'captcha',
{
filter: {
+ origin: 'mobile',
visitorId,
$$createAt$$: {
$gt: now - 3600 * 1000,
@@ -2790,10 +2695,11 @@ export async function sendCaptchaByMobile(
if (mockSend) {
code = mobile.substring(11 - digit);
} else {
- code = Math.floor(Math.random() * Math.pow(10, digit)).toString();
- while (code.length < digit) {
- code += '0';
- }
+ // code = Math.floor(Math.random() * Math.pow(10, digit)).toString();
+ // while (code.length < digit) {
+ // code += '0';
+ // }
+ code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join('');
}
const id = await generateNewIdAsync();
@@ -2826,7 +2732,22 @@ export async function sendCaptchaByMobile(
if (now - (captcha.$$createAt$$! as number) < captchaDuration) {
closeRootMode();
throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
- }
+ }
+ await context.operate(
+ 'captcha',
+ {
+ id: await generateNewIdAsync(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captcha.id!
+ }
+ },
+ {}
+ );
+ code = await getCode();
} else {
code = await getCode();
}
@@ -2872,54 +2793,11 @@ export async function sendCaptchaByEmail(
if (type === 'web' || type === 'native') {
visitorId = env.visitorId;
}
- const application = context.getApplication();
- const { system } = application!;
- const [applicationPassport] = await context.select('applicationPassport',
- {
- data: {
- id: 1,
- passportId: 1,
- passport: {
- id: 1,
- config: 1,
- type: 1,
- },
- applicationId: 1,
- },
- filter: {
- applicationId: application?.id!,
- passport: {
- type: 'email'
- },
- }
- },
- {
- dontCollect: true,
- }
- );
- assert(applicationPassport?.passport);
- const config = applicationPassport.passport.config as EmailConfig;
- const emailConfig = system?.config.Emails?.find((ele) => ele.account === config.account);
- assert(emailConfig);
+
+ const { config, emailConfig } = await getAndCheckPassportByEmail(context, email);
const duration = config.codeDuration || 5;
const digit = config.digit || 4;
const mockSend = config.mockSend;
- const emailSuffixes = config.emailSuffixes;
-
- // 检查邮箱后缀是否满足配置
- if (emailSuffixes?.length! > 0) {
- let isValid = false;
- for (const suffix of emailSuffixes!) {
- if (email.endsWith(suffix)) {
- isValid = true;
- break;
- }
- }
-
- if (!isValid) {
- throw new OakUserException('邮箱后缀不符合要求')
- }
- }
let emailOptions: EmailOptions = {
// host: emailConfig.host,
@@ -2942,6 +2820,7 @@ export async function sendCaptchaByEmail(
'captcha',
{
filter: {
+ origin: 'email',
visitorId,
$$createAt$$: {
$gt: now - 3600 * 1000,
@@ -3000,10 +2879,11 @@ export async function sendCaptchaByEmail(
const getCode = async () => {
let code: string;
- code = Math.floor(Math.random() * Math.random() * Math.pow(10, digit)).toString();
- while (code.length < digit) {
- code += '0';
- }
+ // code = Math.floor(Math.random() * Math.random() * Math.pow(10, digit)).toString();
+ // while (code.length < digit) {
+ // code += '0';
+ // }
+ code = Array.from({ length: digit }, () => Math.floor(Math.random() * 10)).join('');
const id = await generateNewIdAsync();
await context.operate(
'captcha',
@@ -3036,6 +2916,21 @@ export async function sendCaptchaByEmail(
closeRootMode();
throw new OakUserException('您的操作太迅捷啦,请稍候再点吧');
}
+ await context.operate(
+ 'captcha',
+ {
+ id: await generateNewIdAsync(),
+ action: 'update',
+ data: {
+ expired: true
+ },
+ filter: {
+ id: captcha.id!
+ }
+ },
+ {}
+ );
+ code = await getCode();
} else {
code = await getCode();
}
diff --git a/src/components/config/application/web/index.tsx b/src/components/config/application/web/index.tsx
index 337fbfad7..058e08848 100644
--- a/src/components/config/application/web/index.tsx
+++ b/src/components/config/application/web/index.tsx
@@ -91,6 +91,47 @@ export default function Web(props: {
+
+
+ 网站-微信支付
+
+
+ <>
+
+ setValue(`wechatPay.appId`, e.target.value)
+ }
+ />
+ >
+
+
+ <>
+
+ setValue(`wechatPay.appSecret`, e.target.value)
+ }
+ />
+ >
+
+
+
+
location
@@ -158,62 +199,6 @@ export default function Web(props: {
-
- {/*
-
- 网站-授权方式
-
-
- <>
-
-
- */}
);
}
\ No newline at end of file
diff --git a/src/components/config/application/wechatPublic/index.tsx b/src/components/config/application/wechatPublic/index.tsx
index 91bac8db7..e859f8b2f 100644
--- a/src/components/config/application/wechatPublic/index.tsx
+++ b/src/components/config/application/wechatPublic/index.tsx
@@ -35,7 +35,6 @@ export default function WechatPublic(props: {
const [messageType, setMessageType] = useState('');
const { config, setValue, cleanKey, removeItem, isService = true } = props;
- const templateMsgs = config?.templateMsgs || {};
return (
diff --git a/src/entities/Application.ts b/src/entities/Application.ts
index 3a9e3a150..4fbdbdb32 100644
--- a/src/entities/Application.ts
+++ b/src/entities/Application.ts
@@ -33,6 +33,10 @@ export type WebConfig = {
domain?: string;
enable?: boolean; //启用扫码登录
};
+ wechatPay?: {
+ appId: string;
+ appSecret: string; //微信支付
+ };
passport?: Passport[];
location: {
protocol: 'http:' | 'https:';
@@ -41,7 +45,6 @@ export type WebConfig = {
}
};
-export type WechatPublicTemplateMsgsConfig = Record; // key值代表messageTypeId,value的值代表对应的templateId,data的转换改成message上的函数注入
export type WechatPublicConfig = {
type: 'wechatPublic';
@@ -49,7 +52,6 @@ export type WechatPublicConfig = {
appId: string;
appSecret: string;
originalId?: string; //原始id
- templateMsgs?: WechatPublicTemplateMsgsConfig;
server?: {
url?: string; //服务器地址(URL)
token: string; //令牌(Token)
diff --git a/src/types/Config.ts b/src/types/Config.ts
index 5a4d38e53..3e0780c63 100644
--- a/src/types/Config.ts
+++ b/src/types/Config.ts
@@ -12,10 +12,10 @@ export type QiniuLiveConfig = {
liveHost: string; // 七牛直播云接口域名
hub: string; // 直播空间名,
publishDomain: string; // 推流域名
- playDomainType: 'rtmp' | 'hls' | 'flv'; //拉流域名类型
+ playDomainType?: 'rtmp' | 'hls' | 'flv'; //拉流域名类型
playDomain: string; // 拉流域名
playBackDomain: string; // 直播回放存储域名
- publishSecurity: 'none' | 'static' | 'expiry' | 'expiry_sk'; //推流鉴权方式:'none':无校验鉴权;'static':静态鉴权;'expiry':限时鉴权;'expiry_sk':限时鉴权sk
+ publishSecurity?: 'none' | 'static' | 'expiry' | 'expiry_sk'; //推流鉴权方式:'none':无校验鉴权;'static':静态鉴权;'expiry':限时鉴权;'expiry_sk':限时鉴权sk
publishKey: string; // 直播空间限时鉴权密钥 用于static和expiry类型的推流鉴权方式 expiry_sk使用accessKey和secretKey
playKey: string; // 拉流密钥(防盗链主密钥) 若为空则为未开启防盗链
}
diff --git a/src/utils/livestream.ts b/src/utils/livestream.ts
index 1d196a208..b7b29cbc0 100644
--- a/src/utils/livestream.ts
+++ b/src/utils/livestream.ts
@@ -39,7 +39,7 @@ export async function getLivestream(
+ context: BRC,
+ email: string
+) {
+ const application = context.getApplication();
+ const { system } = application!;
+ const [applicationPassport] = await context.select(
+ 'applicationPassport',
+ {
+ data: {
+ id: 1,
+ passportId: 1,
+ passport: {
+ id: 1,
+ config: 1,
+ type: 1,
+ },
+ applicationId: 1,
+ },
+ filter: {
+ applicationId: application?.id!,
+ passport: {
+ type: 'email',
+ },
+ },
+ },
+ {
+ dontCollect: true,
+ }
+ );
+ assert(applicationPassport?.passport);
+ const config = applicationPassport.passport.config as EmailConfig;
+ const emailConfig = system?.config.Emails?.find(
+ (ele) => ele.account === config.account
+ );
+ assert(emailConfig);
+ const emailSuffixes = config.emailSuffixes;
+
+ // 检查邮箱后缀是否满足配置
+ if (emailSuffixes?.length! > 0) {
+ let isValid = false;
+ for (const suffix of emailSuffixes!) {
+ if (email.endsWith(suffix)) {
+ isValid = true;
+ break;
+ }
+ }
+
+ if (!isValid) {
+ throw new OakUserException('error::user.emailSuffixIsInvalid');
+ }
+ }
+
+ return {
+ emailConfig,
+ config
+ };
+}
\ No newline at end of file
diff --git a/template/data.ts b/template/data.ts
index c76175b9f..388884e14 100644
--- a/template/data.ts
+++ b/template/data.ts
@@ -118,6 +118,8 @@ export const system: System[] = [
publishKey: '',
playKey: '',
playBackDomain: '',
+ playDomainType: 'rtmp',
+ publishSecurity: 'none',
},
},
Account: {