From 641ffd4b1f472663c893be2ea6f03b1ef59ac539 Mon Sep 17 00:00:00 2001 From: wkj <278599135@.com> Date: Thu, 26 Jun 2025 18:46:54 +0800 Subject: [PATCH] =?UTF-8?q?application=20web=E7=B1=BB=E5=9E=8B=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/aspects/token.js | 168 +--------------- es/components/config/application/web/index.js | 74 ++----- .../config/application/wechatPublic/index.js | 1 - .../config/style/platform/index.d.ts | 2 +- es/components/extraFile/commit/index.d.ts | 2 +- es/components/wechatLogin/qrCode/index.d.ts | 2 +- es/entities/Application.d.ts | 6 +- .../Application/_baseSchema.d.ts | 6 +- es/triggers/index.d.ts | 2 +- es/triggers/toDo.d.ts | 2 +- es/utils/passport.d.ts | 7 + es/utils/passport.js | 48 +++++ lib/aspects/token.js | 168 +--------------- lib/entities/Application.d.ts | 6 +- .../Application/_baseSchema.d.ts | 6 +- lib/triggers/index.d.ts | 2 +- lib/utils/livestream.js | 7 +- lib/utils/passport.d.ts | 7 + lib/utils/passport.js | 52 +++++ src/aspects/token.ts | 184 +----------------- .../config/application/web/index.tsx | 97 ++++----- .../config/application/wechatPublic/index.tsx | 1 - src/entities/Application.ts | 6 +- src/utils/passport.ts | 63 ++++++ 24 files changed, 284 insertions(+), 635 deletions(-) create mode 100644 es/utils/passport.d.ts create mode 100644 es/utils/passport.js create mode 100644 lib/utils/passport.d.ts create mode 100644 lib/utils/passport.js create mode 100644 src/utils/passport.ts diff --git a/es/aspects/token.js b/es/aspects/token.js index 6571114d0..402ccf83a 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: { @@ -560,49 +561,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 +939,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: { @@ -1233,46 +1153,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, @@ -2168,49 +2049,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, 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) { - - {/* - - 网站-授权方式 - -
- - <> - + setValue(`wechatPay.appId`, e.target.value) + } + /> + + + + <> + + setValue(`wechatPay.appSecret`, e.target.value) + } + /> + + +
+ + location @@ -158,62 +199,6 @@ export default function Web(props: { - - {/* - - 网站-授权方式 - -
- - <> -