diff --git a/frontend/src/pages/Login.tsx b/frontend/src/pages/Login.tsx index ff58cfd..caa3417 100644 --- a/frontend/src/pages/Login.tsx +++ b/frontend/src/pages/Login.tsx @@ -1,23 +1,17 @@ -import React, { useState, useEffect } from 'react'; -import { useNavigate, useSearchParams } from 'react-router-dom'; +import React, { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import axios from 'axios'; import { API_BASE_URL } from '../config'; export const Login: React.FC = () => { + const [sessionId, setSessionId] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); - const [searchParams] = useSearchParams(); const navigate = useNavigate(); - // Check if we have a sessionid from URL (bookmarklet redirect) - useEffect(() => { - const sessionIdFromUrl = searchParams.get('sessionid'); - if (sessionIdFromUrl) { - handleAutoConnect(sessionIdFromUrl); - } - }, [searchParams]); + const handleConnect = async () => { + if (!sessionId.trim()) return; - const handleAutoConnect = async (sessionId: string) => { setError(''); setIsLoading(true); @@ -25,7 +19,7 @@ export const Login: React.FC = () => { const res = await axios.post(`${API_BASE_URL}/auth/credentials`, { credentials: { http: { - cookies: { sessionid: sessionId } + cookies: { sessionid: sessionId.trim() } } } }); @@ -33,39 +27,23 @@ export const Login: React.FC = () => { if (res.data.status === 'success') { navigate('/'); } else { - setError('Connection failed. Please try again.'); - setIsLoading(false); + setError('Connection failed. Please check your session ID.'); } } catch (err: any) { - setError('Invalid session. Please try again.'); + setError('Invalid session ID. Please try again.'); + } finally { setIsLoading(false); } }; - // Get the current app URL for bookmarklet redirect - const appUrl = window.location.origin; - - // Bookmarklet code - extracts sessionid and redirects back - const bookmarkletCode = `javascript:(function(){var c=document.cookie.split(';');var s='';for(var i=0;i { - navigator.clipboard.writeText(bookmarkletCode); - alert('Bookmarklet code copied! Create a new bookmark and paste this as the URL.'); + const openTikTokLogin = () => { + window.open('https://www.tiktok.com/login', '_blank'); }; - if (isLoading) { - return ( -
-
-

Connecting to TikTok...

-
- ); - } - return (
{/* Header */} -
+
@@ -87,59 +65,90 @@ export const Login: React.FC = () => {
)} - {/* One-Time Setup (Desktop) */} -
-

- 🖥️ Desktop Setup (One-Time) -

-
    -
  1. - 1. - Drag this button to your bookmarks bar: -
  2. -
- - {/* Draggable Bookmarklet */} - e.preventDefault()} - onDragEnd={() => { }} - className="inline-block py-2 px-4 bg-gradient-to-r from-pink-500 to-orange-500 text-white font-bold rounded-lg text-sm cursor-grab active:cursor-grabbing shadow-lg mb-4" - title="Drag me to your bookmarks bar!" - > - 📎 Get PureStream - - -

- Can't drag? and create a bookmark manually. + {/* Important Note */} +

+

+ ⚠️ This requires a desktop/laptop computer with Chrome or Firefox

- {/* How to Use */} -
-

- 📱 How to Connect -

-
    -
  1. -
    1
    - Go to tiktok.com and login with your account -
  2. -
  3. -
    2
    - Click the "📎 Get PureStream" bookmark -
  4. -
  5. -
    3
    - You'll be automatically redirected and logged in! -
  6. -
+ {/* Steps */} +
+
+
1
+
+

Login to TikTok on desktop

+ +
+
+ +
+
2
+
+

Open DevTools & copy sessionid

+
+

• Press F12 or Ctrl+Shift+I

+

• Click Application tab

+

• Click Cookiestiktok.com

+

• Find sessionid and copy its value

+
+
+
+ +
+
3
+
+

Paste here and connect

+ setSessionId(e.target.value)} + placeholder="Paste sessionid value..." + className="w-full bg-black border-2 border-white/10 rounded-lg p-3 text-white text-sm font-mono focus:outline-none focus:border-pink-500/50 placeholder:text-gray-600" + disabled={isLoading} + /> +
+
- {/* Note */} -

- The bookmarklet securely reads your TikTok session and connects it to PureStream. -

+ {/* Connect Button */} + + + {/* Help */} +