mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-03 15:06:36 +08:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # AGENTS.md # backend/docs/docs.go # backend/docs/swagger.json # backend/docs/swagger.yaml # frontend/components/providers/title-updater.tsx # frontend/messages/fragments/admin.en.json # frontend/messages/fragments/admin.zh-CN.json # frontend/proxy.ts
This commit is contained in:
@@ -46,7 +46,7 @@ interface AuthHeadingProps {
|
||||
export function AuthHeading({
|
||||
title,
|
||||
description,
|
||||
siteName = 'Wavelet',
|
||||
siteName = 'OpenFlare',
|
||||
}: AuthHeadingProps) {
|
||||
return (
|
||||
<header className='flex flex-col gap-6 [@media(max-height:700px)]:gap-3'>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useSearchParams } from 'next/navigation';
|
||||
import { EyeIcon, EyeOffIcon } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import Link from 'next/link';
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import { useAuth } from '@/components/providers/auth-provider';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -19,7 +20,6 @@ import { OTPForm } from './otp-form';
|
||||
import { AuthService } from '@/lib/services/auth';
|
||||
import { ConfigService } from '@/lib/services/config';
|
||||
import type { LoginRequest } from '@/lib/services/auth/types';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { safeRedirectTarget } from '@/lib/utils';
|
||||
|
||||
function persistRedirectTarget(
|
||||
@@ -198,8 +198,8 @@ export function LoginForm({
|
||||
};
|
||||
|
||||
const registrationEnabled =
|
||||
configBool(publicConfigQuery.data?.registration_enabled, true) &&
|
||||
configBool(publicConfigQuery.data?.password_register_enabled, true);
|
||||
configBool(publicConfigQuery.data?.registration_enabled, false) &&
|
||||
configBool(publicConfigQuery.data?.password_register_enabled, false);
|
||||
|
||||
const passwordLoginEnabled = configBool(
|
||||
publicConfigQuery.data?.password_login_enabled,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Check } from 'lucide-react';
|
||||
import { AuthService } from '@/lib/services/auth';
|
||||
import { useAuth } from '@/components/providers/auth-provider';
|
||||
import { safeRedirectTarget } from '@/lib/utils';
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
/**
|
||||
* 登录页面组件
|
||||
@@ -27,6 +28,7 @@ export function LoginPage() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { user, loading, setUser } = useAuth();
|
||||
const t = useTranslations('auth.login');
|
||||
const [showOTP, setShowOTP] = useState(false);
|
||||
|
||||
/* 处理OAuth回调 */
|
||||
@@ -44,7 +46,7 @@ export function LoginPage() {
|
||||
const resolveRedirectTarget = useCallback(() => {
|
||||
const callbackUrl = searchParams.get('callbackUrl');
|
||||
const storedRedirect = sessionStorage.getItem('redirect_after_login');
|
||||
const target = callbackUrl || storedRedirect || '/home';
|
||||
const target = callbackUrl || storedRedirect || '/';
|
||||
|
||||
if (storedRedirect) {
|
||||
sessionStorage.removeItem('redirect_after_login');
|
||||
@@ -87,9 +89,7 @@ export function LoginPage() {
|
||||
try {
|
||||
const result = await AuthService.handleCallback({ state, code });
|
||||
if (result.status === 'need_bind') {
|
||||
toast.info(
|
||||
'您的第三方账号未绑定本地账号,系统已关闭注册。请登录已有本地账号进行绑定。',
|
||||
);
|
||||
toast.info(t('needBind'));
|
||||
setIsProcessingCallback(false);
|
||||
router.replace('/login');
|
||||
return;
|
||||
@@ -98,7 +98,9 @@ export function LoginPage() {
|
||||
setUser(result.user);
|
||||
}
|
||||
setLoginSuccess(true);
|
||||
toast.success(result.status === 'bound' ? '绑定成功' : '登录成功');
|
||||
toast.success(
|
||||
result.status === 'bound' ? t('bindSuccess') : t('success'),
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
if (!redirectedRef.current) {
|
||||
@@ -108,16 +110,14 @@ export function LoginPage() {
|
||||
}, 1500);
|
||||
} catch (error) {
|
||||
console.error('OAuth callback error:', error);
|
||||
toast.error(
|
||||
error instanceof Error ? error.message : '登录失败,请重试',
|
||||
);
|
||||
toast.error(error instanceof Error ? error.message : t('failed'));
|
||||
setIsProcessingCallback(false);
|
||||
router.replace('/login');
|
||||
}
|
||||
}
|
||||
};
|
||||
handleOAuthCallback();
|
||||
}, [router, searchParams, setUser]);
|
||||
}, [router, searchParams, setUser, t]);
|
||||
|
||||
return (
|
||||
<AuthShell wide={showOTP}>
|
||||
@@ -138,10 +138,10 @@ export function LoginPage() {
|
||||
</div>
|
||||
<div className='flex flex-col gap-2 text-center'>
|
||||
<h3 className='font-semibold tracking-tight text-foreground'>
|
||||
正在检查登录状态
|
||||
{t('checkingSession')}
|
||||
</h3>
|
||||
<p className='text-xs text-muted-foreground'>
|
||||
请稍候,我们正在确认当前会话...
|
||||
{t('checkingSessionDesc')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -157,10 +157,10 @@ export function LoginPage() {
|
||||
</motion.div>
|
||||
<div className='flex flex-col gap-2 text-center'>
|
||||
<h3 className='font-semibold tracking-tight text-foreground'>
|
||||
登录成功
|
||||
{t('success')}
|
||||
</h3>
|
||||
<p className='text-xs text-muted-foreground'>
|
||||
正在跳转至控制台...
|
||||
{t('redirecting')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -171,10 +171,10 @@ export function LoginPage() {
|
||||
</div>
|
||||
<div className='flex flex-col gap-2 text-center'>
|
||||
<h3 className='font-semibold tracking-tight text-foreground'>
|
||||
正在验证凭据
|
||||
{t('verifyingCredentials')}
|
||||
</h3>
|
||||
<p className='text-xs text-muted-foreground'>
|
||||
请稍候,我们正在为您建立安全会话...
|
||||
{t('establishingSession')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@ function getRedirectTarget(searchParams: ReturnType<typeof useSearchParams>) {
|
||||
typeof window === 'undefined'
|
||||
? null
|
||||
: sessionStorage.getItem('redirect_after_login');
|
||||
return safeRedirectTarget(callbackUrl || storedRedirect || '/home');
|
||||
return safeRedirectTarget(callbackUrl || storedRedirect || '/');
|
||||
}
|
||||
|
||||
function configBool(value: string | undefined, fallback: boolean) {
|
||||
@@ -68,8 +68,8 @@ export function RegisterForm() {
|
||||
);
|
||||
|
||||
const registrationEnabled =
|
||||
configBool(publicConfigQuery.data?.registration_enabled, true) &&
|
||||
configBool(publicConfigQuery.data?.password_register_enabled, true);
|
||||
configBool(publicConfigQuery.data?.registration_enabled, false) &&
|
||||
configBool(publicConfigQuery.data?.password_register_enabled, false);
|
||||
|
||||
const emailRegisterEnabled = configBool(
|
||||
publicConfigQuery.data?.email_register_verification_enabled,
|
||||
|
||||
Reference in New Issue
Block a user