🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
📝 docs(auth): add i18n support for auth plugin error messages (#11824)
YuTengjing8544cf97a2ba
diff --git a/locales/zh-CN/authError.json b/locales/zh-CN/authError.jsonindex f944a78f31d..64fd24bf849 100644--- a/locales/zh-CN/authError.json+++ b/locales/zh-CN/authError.json@@ -5,7 +5,9 @@"codes.ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_USER": "这个账号已绑定到其他用户,请使用其他方式登录","codes.ACCOUNT_NOT_FOUND": "没有找到对应账号,请检查登录方式或注册新账号","codes.CREDENTIAL_ACCOUNT_NOT_FOUND": "凭证账号不存在,请重新授权或联系支持",+ "codes.DELETED_ACCOUNT_EMAIL": "该邮箱关联的账号已注销,无法再次注册","codes.EMAIL_CAN_NOT_BE_UPDATED": "当前邮箱无法修改,如需更换,请联系支持",+ "codes.EMAIL_NOT_ALLOWED": "该邮箱不允许注册","codes.EMAIL_NOT_VERIFIED": "邮箱还未验证,请先查收验证邮件完成验证","codes.FAILED_TO_CREATE_SESSION": "会话创建遇到了问题。你可以先重试;如仍失败,请检查网络或稍后再试","codes.FAILED_TO_CREATE_USER": "创建用户遇到了问题。你可以稍后再试",diff --git a/src/app/[variants]/(auth)/signup/[[...signup]]/useSignUp.tsx b/src/app/[variants]/(auth)/signup/[[...signup]]/useSignUp.tsxindex e67747bddd9..964a711b358 100644--- a/src/app/[variants]/(auth)/signup/[[...signup]]/useSignUp.tsx+++ b/src/app/[variants]/(auth)/signup/[[...signup]]/useSignUp.tsx@@ -1,6 +1,5 @@import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';import { form } from 'motion/react-m';-import { useRouter, useSearchParams } from '@/libs/next/navigation';import { useState } from 'react';import { useTranslation } from 'react-i18next';@@ -10,6 +9,7 @@ import {} from '@/business/client/hooks/useBusinessSignup';import { message } from '@/components/AntdStaticMethods';import { signUp } from '@/libs/better-auth/auth-client';+import { useRouter, useSearchParams } from '@/libs/next/navigation';import { useServerConfigStore } from '@/store/serverConfig';import { serverConfigSelectors } from '@/store/serverConfig/selectors';@@ -18,7 +18,7 @@ import { BaseSignUpFormValues } from './types';export type SignUpFormValues = BaseSignUpFormValues & BusinessSignupFomData;export const useSignUp = () => {- const { t } = useTranslation('auth');+ const { t } = useTranslation(['auth', 'authError']);const router = useRouter();const searchParams = useSearchParams();const [loading, setLoading] = useState(false);@@ -56,12 +56,15 @@ export const useSignUp = () => {return;}- if (error.code === 'INVALID_EMAIL') {+ if (error.code === 'INVALID_EMAIL' || error.message === 'Invalid email') {message.error(t('betterAuth.errors.emailInvalid'));return;}- message.error(error.message || t('betterAuth.signup.error'));+ const translated = error.code+ ? t(`authError:codes.${error.code}`, { defaultValue: '' })+ : '';+ message.error(translated || error.message || t('betterAuth.signup.error'));return;}diff --git a/src/libs/better-auth/define-config.ts b/src/libs/better-auth/define-config.tsindex 09386092caa..f1bc8568e26 100644--- a/src/libs/better-auth/define-config.ts+++ b/src/libs/better-auth/define-config.ts@@ -35,7 +35,6 @@ import { UserService } from '@/server/services/user';// Ref: https://github.com/better-auth/better-auth/issues/7396if (process.env.NODE_ENV === 'development') {const proxyUrl =- process.env.AUTH_HTTP_PROXY_URL ||process.env.HTTPS_PROXY ||process.env.https_proxy ||process.env.HTTP_PROXY ||@@ -44,7 +43,6 @@ if (process.env.NODE_ENV === 'development') {if (proxyUrl) {const proxyAgent = new ProxyAgent(proxyUrl);setGlobalDispatcher(proxyAgent);- console.log(`[auth] HTTP proxy configured: ${proxyUrl}`);}}diff --git a/src/libs/better-auth/plugins/email-whitelist.ts b/src/libs/better-auth/plugins/email-whitelist.tsindex 05eeaf83f90..9e3f2750d81 100644--- a/src/libs/better-auth/plugins/email-whitelist.ts+++ b/src/libs/better-auth/plugins/email-whitelist.ts@@ -48,7 +48,10 @@ export const emailWhitelist = (): BetterAuthPlugin => ({if (!user.email) return { data: user };if (!isEmailAllowed(user.email)) {- throw new APIError('FORBIDDEN', { message: 'Email not allowed for registration' });+ throw new APIError('FORBIDDEN', {+ code: 'EMAIL_NOT_ALLOWED',+ message: 'EMAIL_NOT_ALLOWED',+ });}return { data: user };diff --git a/src/locales/default/authError.ts b/src/locales/default/authError.tsindex ba7edf3d1a1..9567de7be74 100644--- a/src/locales/default/authError.ts+++ b/src/locales/default/authError.ts@@ -6,7 +6,10 @@ export default {'This account is already linked to another user','codes.ACCOUNT_NOT_FOUND': 'Account not found','codes.CREDENTIAL_ACCOUNT_NOT_FOUND': 'Credential account does not exist',+ 'codes.DELETED_ACCOUNT_EMAIL':+ 'This email has been associated with a deleted account and cannot be used for registration','codes.EMAIL_CAN_NOT_BE_UPDATED': 'Email cannot be updated for this account',+ 'codes.EMAIL_NOT_ALLOWED': 'Email not allowed for registration','codes.EMAIL_NOT_VERIFIED': 'Please verify your email first','codes.FAILED_TO_CREATE_SESSION': 'Failed to create session','codes.FAILED_TO_CREATE_USER': 'Failed to create user',