From 4073a84a7a3cb9cc305d5cb44ede75400ba86885 Mon Sep 17 00:00:00 2001 From: "Khoa.vo" Date: Fri, 19 Dec 2025 15:16:22 +0700 Subject: [PATCH] Two-step login: Open TikTok in new tab, then paste sessionid --- frontend/src/pages/Login.tsx | 145 +++++++++++++++++------------------ 1 file changed, 71 insertions(+), 74 deletions(-) diff --git a/frontend/src/pages/Login.tsx b/frontend/src/pages/Login.tsx index 9db888a..d1eb4d6 100644 --- a/frontend/src/pages/Login.tsx +++ b/frontend/src/pages/Login.tsx @@ -7,17 +7,22 @@ export const Login: React.FC = () => { const [sessionId, setSessionId] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); - const [showInstructions, setShowInstructions] = useState(true); + const [step, setStep] = useState<1 | 2>(1); const navigate = useNavigate(); - const handleLogin = async () => { + const openTikTokLogin = () => { + // Open TikTok login in new tab + window.open('https://www.tiktok.com/login', '_blank'); + setStep(2); + }; + + const handleConnect = async () => { if (!sessionId.trim()) return; setError(''); setIsLoading(true); try { - // Send sessionid as credentials const res = await axios.post(`${API_BASE_URL}/auth/credentials`, { credentials: { http: { @@ -29,10 +34,10 @@ export const Login: React.FC = () => { if (res.data.status === 'success') { navigate('/'); } else { - setError(res.data.message || 'Login failed.'); + setError(res.data.message || 'Connection failed.'); } } catch (err: any) { - setError(err.response?.data?.detail || 'Invalid session. Please try again.'); + setError(err.response?.data?.detail || 'Invalid session ID. Please try again.'); } finally { setIsLoading(false); } @@ -41,7 +46,7 @@ export const Login: React.FC = () => { return (
{/* Header */} -
+
@@ -54,7 +59,7 @@ export const Login: React.FC = () => {

Ad-free TikTok viewing

- {/* Scrollable Content */} + {/* Content */}
{error && ( @@ -63,92 +68,84 @@ export const Login: React.FC = () => {
)} - {/* Instructions Toggle */} - + +

Opens in new tab - login with your account

+
- {showInstructions && ( -
-
-
1
-
-

Open TikTok app → Login

-
-
+ {/* Arrow */} +
+
↓
+
-
-
2
-
-

On desktop: Open TikTok in Chrome

-

F12 → Application → Cookies → tiktok.com

-
-
- -
-
3
-
-

Copy the sessionid value

-

Long string starting with numbers

-
-
+ {/* Step 2: Get Session ID */} +
+
+
2
+ Copy your Session ID +
+ +
+

After logging in on TikTok:

+
    +
  1. Press F12 (or right-click → Inspect)
  2. +
  3. Go to Application → Cookies
  4. +
  5. Find sessionid and copy its value
  6. +
- )} - {/* Session ID Input */} -
- setSessionId(e.target.value)} - placeholder="Paste your sessionid here..." - className="w-full bg-black/60 border-2 border-white/10 rounded-xl p-4 text-white text-sm font-mono focus:outline-none focus:border-cyan-500/50 placeholder:text-gray-600" + placeholder="Paste sessionid value here..." + className="w-full bg-black/60 border-2 border-white/10 rounded-xl p-4 text-white text-sm font-mono focus:outline-none focus:border-cyan-500/50 placeholder:text-gray-600 mb-4" disabled={isLoading} /> + +
- {/* Connect Button */} - - - {/* Video Tutorial Link */} -
+ {/* Help */} + - - {/* Note */} -

- Your session ID connects you to your TikTok account. It's stored locally on the server. -