diff --git a/frontend/desktop/src/pages/api/auth/email/bind/verify.ts b/frontend/desktop/src/pages/api/auth/email/bind/verify.ts index 5c10e97502f..0417788c92f 100644 --- a/frontend/desktop/src/pages/api/auth/email/bind/verify.ts +++ b/frontend/desktop/src/pages/api/auth/email/bind/verify.ts @@ -3,11 +3,11 @@ import { ErrorHandler } from '@/services/backend/middleware/error'; import { bindEmailGuard } from '@/services/backend/middleware/oauth'; import { filterEmailVerifyParams, verifyEmailCodeGuard } from '@/services/backend/middleware/sms'; import { bindEmailSvc } from '@/services/backend/svc/bindProvider'; -import { enablePhoneSms } from '@/services/enable'; +import { enableEmailSms } from '@/services/enable'; import { NextApiRequest, NextApiResponse } from 'next'; export default ErrorHandler(async function handler(req: NextApiRequest, res: NextApiResponse) { - if (!enablePhoneSms()) { + if (!enableEmailSms()) { throw new Error('SMS is not enabled'); } await filterAccessToken( diff --git a/frontend/desktop/src/pages/api/auth/email/changeBinding/newSms.ts b/frontend/desktop/src/pages/api/auth/email/changeBinding/newSms.ts index 0413e4c4e73..911ee217ff9 100644 --- a/frontend/desktop/src/pages/api/auth/email/changeBinding/newSms.ts +++ b/frontend/desktop/src/pages/api/auth/email/changeBinding/newSms.ts @@ -6,10 +6,10 @@ import { sendNewEmailCodeGuard } from '@/services/backend/middleware/sms'; import { sendEmailCodeSvc } from '@/services/backend/svc/sms'; -import { enablePhoneSms } from '@/services/enable'; +import { enableEmailSms } from '@/services/enable'; import { NextApiRequest, NextApiResponse } from 'next'; export default ErrorHandler(async function handler(req: NextApiRequest, res: NextApiResponse) { - if (!enablePhoneSms()) { + if (!enableEmailSms()) { throw new Error('SMS is not enabled'); } await filterAccessToken(req, res, ({ userUid }) => diff --git a/frontend/desktop/src/pages/api/auth/email/changeBinding/oldSms.ts b/frontend/desktop/src/pages/api/auth/email/changeBinding/oldSms.ts index d9c3dc24ddf..adb279d0341 100644 --- a/frontend/desktop/src/pages/api/auth/email/changeBinding/oldSms.ts +++ b/frontend/desktop/src/pages/api/auth/email/changeBinding/oldSms.ts @@ -3,10 +3,10 @@ import { ErrorHandler } from '@/services/backend/middleware/error'; import { unbindEmailGuard } from '@/services/backend/middleware/oauth'; import { filterEmailParams, sendEmailCodeGuard } from '@/services/backend/middleware/sms'; import { sendEmailCodeSvc } from '@/services/backend/svc/sms'; -import { enablePhoneSms } from '@/services/enable'; +import { enableEmailSms } from '@/services/enable'; import { NextApiRequest, NextApiResponse } from 'next'; export default ErrorHandler(async function handler(req: NextApiRequest, res: NextApiResponse) { - if (!enablePhoneSms()) { + if (!enableEmailSms()) { throw new Error('SMS is not enabled'); } await filterAccessToken(req, res, ({ userUid }) => diff --git a/frontend/desktop/src/pages/api/auth/email/changeBinding/verifyNew.ts b/frontend/desktop/src/pages/api/auth/email/changeBinding/verifyNew.ts index b39eeba9cc5..2940f93e1b8 100644 --- a/frontend/desktop/src/pages/api/auth/email/changeBinding/verifyNew.ts +++ b/frontend/desktop/src/pages/api/auth/email/changeBinding/verifyNew.ts @@ -8,11 +8,11 @@ import { verifyEmailCodeGuard } from '@/services/backend/middleware/sms'; import { changeEmailBindingSvc } from '@/services/backend/svc/bindProvider'; -import { enablePhoneSms } from '@/services/enable'; +import { enableEmailSms } from '@/services/enable'; import { NextApiRequest, NextApiResponse } from 'next'; export default ErrorHandler(async function handler(req: NextApiRequest, res: NextApiResponse) { - if (!enablePhoneSms()) { + if (!enableEmailSms()) { throw new Error('SMS is not enabled'); } await filterAccessToken(req, res, ({ userUid }) => diff --git a/frontend/desktop/src/pages/api/auth/email/changeBinding/verifyOld.ts b/frontend/desktop/src/pages/api/auth/email/changeBinding/verifyOld.ts index 0a27b76d207..e2e34b3daf2 100644 --- a/frontend/desktop/src/pages/api/auth/email/changeBinding/verifyOld.ts +++ b/frontend/desktop/src/pages/api/auth/email/changeBinding/verifyOld.ts @@ -3,11 +3,11 @@ import { ErrorHandler } from '@/services/backend/middleware/error'; import { unbindEmailGuard } from '@/services/backend/middleware/oauth'; import { filterEmailVerifyParams, verifyEmailCodeGuard } from '@/services/backend/middleware/sms'; import { jsonRes } from '@/services/backend/response'; -import { enablePhoneSms } from '@/services/enable'; +import { enableEmailSms } from '@/services/enable'; import { NextApiRequest, NextApiResponse } from 'next'; export default ErrorHandler(async function handler(req: NextApiRequest, res: NextApiResponse) { - if (!enablePhoneSms()) { + if (!enableEmailSms()) { throw new Error('SMS is not enabled'); } await filterAccessToken( diff --git a/frontend/desktop/src/pages/api/auth/email/unbind/sms.ts b/frontend/desktop/src/pages/api/auth/email/unbind/sms.ts index dd7650de720..23aec48d60b 100644 --- a/frontend/desktop/src/pages/api/auth/email/unbind/sms.ts +++ b/frontend/desktop/src/pages/api/auth/email/unbind/sms.ts @@ -3,11 +3,11 @@ import { ErrorHandler } from '@/services/backend/middleware/error'; import { unbindEmailGuard } from '@/services/backend/middleware/oauth'; import { filterCf, filterEmailParams, sendEmailCodeGuard } from '@/services/backend/middleware/sms'; import { sendEmailCodeSvc } from '@/services/backend/svc/sms'; -import { enablePhoneSms } from '@/services/enable'; +import { enableEmailSms } from '@/services/enable'; import { NextApiRequest, NextApiResponse } from 'next'; export default ErrorHandler(async function handler(req: NextApiRequest, res: NextApiResponse) { - if (!enablePhoneSms()) { + if (!enableEmailSms()) { throw new Error('SMS is not enabled'); } await filterAccessToken(req, res, ({ userUid }) => diff --git a/frontend/desktop/src/pages/api/auth/email/unbind/verify.ts b/frontend/desktop/src/pages/api/auth/email/unbind/verify.ts index 3ded4697279..e3f84dbf812 100644 --- a/frontend/desktop/src/pages/api/auth/email/unbind/verify.ts +++ b/frontend/desktop/src/pages/api/auth/email/unbind/verify.ts @@ -2,11 +2,11 @@ import { filterAccessToken } from '@/services/backend/middleware/access'; import { ErrorHandler } from '@/services/backend/middleware/error'; import { filterEmailVerifyParams, verifyEmailCodeGuard } from '@/services/backend/middleware/sms'; import { unbindEmailSvc } from '@/services/backend/svc/bindProvider'; -import { enablePhoneSms } from '@/services/enable'; +import { enableEmailSms } from '@/services/enable'; import { NextApiRequest, NextApiResponse } from 'next'; export default ErrorHandler(async function handler(req: NextApiRequest, res: NextApiResponse) { - if (!enablePhoneSms()) { + if (!enableEmailSms()) { throw new Error('SMS is not enabled'); } await filterAccessToken(req, res, ({ userUid }) => diff --git a/frontend/desktop/src/pages/api/auth/info.ts b/frontend/desktop/src/pages/api/auth/info.ts index 3390bf44440..cdb11082c91 100644 --- a/frontend/desktop/src/pages/api/auth/info.ts +++ b/frontend/desktop/src/pages/api/auth/info.ts @@ -6,7 +6,8 @@ import { enableGithub, enableGoogle, enablePassword, - enablePhoneSms + enablePhoneSms, + enableWechat } from '@/services/enable'; import { NextApiRequest, NextApiResponse } from 'next'; import { ProviderType } from 'prisma/global/generated/client'; @@ -89,6 +90,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) return enableEmailSms(); } else if (o.providerType === ProviderType.PASSWORD) { return enablePassword(); + } else if (o.providerType === ProviderType.WECHAT) { + return enableWechat(); } return true; }) diff --git a/frontend/desktop/src/services/enable.ts b/frontend/desktop/src/services/enable.ts index 91f700d9a00..4cd4da93813 100644 --- a/frontend/desktop/src/services/enable.ts +++ b/frontend/desktop/src/services/enable.ts @@ -4,9 +4,11 @@ export const enableEnterpriseRealNameAuth = () => global.AppConfig.common.enterpriseRealNameAuthEnabled || false; export const enablePassword = () => global.AppConfig.desktop.auth.idp.password?.enabled || false; export const enableGithub = () => global.AppConfig.desktop.auth.idp.github?.enabled || false; -export const enablePhoneSms = () => global.AppConfig.desktop.auth.idp.sms?.ali?.enabled || false; export const enableSms = () => global.AppConfig.desktop.auth.idp.sms?.enabled || false; -export const enableEmailSms = () => global.AppConfig.desktop.auth.idp.sms?.email?.enabled || false; +export const enablePhoneSms = () => + enableSms() && !!global.AppConfig.desktop.auth.idp.sms?.ali?.enabled; +export const enableEmailSms = () => + enableSms() && !!global.AppConfig.desktop.auth.idp.sms?.email?.enabled; export const enableWechat = () => global.AppConfig.desktop.auth.idp.wechat?.enabled || false; export const enableGoogle = () => global.AppConfig.desktop.auth.idp.google?.enabled || false; export const enableSignUp = () => global.AppConfig.desktop.auth.signUpEnabled || false;