diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx
index 9ba4b78..45f5182 100644
--- a/src/pages/Login.tsx
+++ b/src/pages/Login.tsx
@@ -3,7 +3,7 @@ import { useNavigate, useLocation, useSearchParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { useQuery } from '@tanstack/react-query'
import { useAuthStore } from '../store/auth'
-import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo, isLogoPreloaded, type BrandingInfo } from '../api/branding'
+import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo, isLogoPreloaded, type BrandingInfo, type EmailAuthEnabled } from '../api/branding'
import { getAndClearReturnUrl } from '../utils/token'
import LanguageSwitcher from '../components/LanguageSwitcher'
import TelegramLoginButton from '../components/TelegramLoginButton'
@@ -65,7 +65,29 @@ export default function Login() {
initialData: cachedBranding ?? undefined,
})
+ // Check if email auth is enabled
+ const { data: emailAuthConfig } = useQuery({
+ queryKey: ['email-auth-enabled'],
+ queryFn: brandingApi.getEmailAuthEnabled,
+ staleTime: 60000,
+ })
+ const isEmailAuthEnabled = emailAuthConfig?.enabled ?? true
+
const botUsername = import.meta.env.VITE_TELEGRAM_BOT_USERNAME || ''
+
+ // If email auth is disabled but user came with ref param, redirect to bot
+ useEffect(() => {
+ if (referralCode && emailAuthConfig?.enabled === false && botUsername) {
+ window.location.href = `https://t.me/${botUsername}?start=ref_${referralCode}`
+ }
+ }, [referralCode, emailAuthConfig, botUsername])
+
+ // If email auth is disabled but we initially set to email tab, switch back to telegram
+ useEffect(() => {
+ if (!isEmailAuthEnabled && activeTab === 'email') {
+ setActiveTab('telegram')
+ }
+ }, [isEmailAuthEnabled, activeTab])
const appName = branding ? branding.name : (import.meta.env.VITE_APP_NAME || 'VPN')
const appLogo = branding?.logo_letter || import.meta.env.VITE_APP_LOGO || 'V'
const logoUrl = branding ? brandingApi.getLogoUrl(branding) : null
@@ -202,8 +224,8 @@ export default function Login() {
{t('auth.loginSubtitle')}
- {/* Referral Banner */}
- {referralCode && (
+ {/* Referral Banner - only show when email auth is enabled */}
+ {referralCode && isEmailAuthEnabled && (