Spaces:
Sleeping
Sleeping
Download web/src/Login.tsx from DeepThoughtAI/evo-frontend: direct link, hf CLI and curl.
- Browser
- Download file 6.69 kB
-
https://huggingface.co/spaces/DeepThoughtAI/evo-frontend/resolve/main/web/src/Login.tsx
- Command line
-
hf download hf://spaces/DeepThoughtAI/evo-frontend/web/src/Login.tsx
-
curl -L -o Login.tsx https://huggingface.co/spaces/DeepThoughtAI/evo-frontend/resolve/main/web/src/Login.tsx
6.69 kB
| import React, { useMemo, useState } from 'react'; | |
| const LOGIC_SAYINGS = [ | |
| "Logic is disciplined honesty", | |
| "Logic tames intuition", | |
| "Logic survives scrutiny", | |
| "Logic resists wishful thinking", | |
| "Logic clarifies chaos", | |
| "Logic enforces consistency", | |
| "Logic demands consequences", | |
| "Logic hates contradiction", | |
| "Logic respects structure", | |
| "Logic questions assumptions", | |
| "Logic over loud opinions", | |
| "Logic scales beyond intuition", | |
| "Logic is structured doubt", | |
| "Logic follows necessity", | |
| "Logic earns trust", | |
| "Logic trims nonsense", | |
| "Logic values implication", | |
| "Logic prevents self-deception", | |
| "Logic is careful thinking", | |
| "Logic disciplines belief", | |
| "Logic outlives emotion", | |
| "Logic defines fairness", | |
| "Logic reveals errors", | |
| "Logic needs no applause", | |
| "Logic is patient clarity", | |
| "Logic refuses shortcuts", | |
| "Logic enforces coherence", | |
| "Logic invites verification", | |
| "Logic keeps promises", | |
| "Logic respects evidence", | |
| "Logic cuts cleanly", | |
| "Logic exposes contradictions", | |
| "Logic is structured reasoning", | |
| "Logic defeats ambiguity", | |
| "Logic rejects special pleading", | |
| "Logic anchors truth", | |
| "Logic strengthens arguments", | |
| "Logic filters belief", | |
| "Logic withstands pressure", | |
| "Logic enables understanding", | |
| "Logic is mental hygiene", | |
| "Logic values consistency", | |
| "Logic guards intelligence", | |
| "Logic is intellectual integrity", | |
| "Logic reveals necessity", | |
| "Logic is consequence-aware", | |
| "Logic clarifies premises", | |
| "Logic enforces discipline", | |
| "Logic refines thought", | |
| "Logic avoids contradiction", | |
| "Logic resists manipulation", | |
| "Logic empowers truth", | |
| "Logic disciplines intuition", | |
| "Logic respects implication", | |
| "Logic is rigorous thinking", | |
| "Logic survives opposition", | |
| "Logic rejects ambiguity", | |
| "Logic is systematic clarity", | |
| "Logic curbs bias", | |
| "Logic anchors reasoning", | |
| "Logic exposes fallacies", | |
| "Logic enforces structure", | |
| "Logic is formal honesty", | |
| "Logic strengthens insight", | |
| "Logic trims assumptions", | |
| "Logic invites challenge", | |
| "Logic prefers coherence", | |
| "Logic defeats confusion", | |
| "Logic remains impartial", | |
| "Logic respects consequences", | |
| "Logic makes sense durable", | |
| "Logic tests belief", | |
| "Logic values precision", | |
| "Logic demands justification", | |
| "Logic refines arguments", | |
| "Logic guards truth", | |
| "Logic stabilizes thought", | |
| "Logic is disciplined skepticism", | |
| "Logic clarifies meaning", | |
| "Logic enforces necessity", | |
| "Logic rejects contradictions", | |
| "Logic sustains reasoning", | |
| "Logic keeps ideas honest", | |
| "Logic enforces fairness", | |
| "Logic structures understanding", | |
| "Logic prevents nonsense", | |
| "Logic respects reality", | |
| "Logic rejects inconsistency", | |
| "Logic sharpens clarity", | |
| "Logic enables precision", | |
| "Logic stabilizes belief", | |
| "Logic resists illusion", | |
| "Logic enforces truthfulness", | |
| "Logic exposes inconsistency", | |
| "Logic refines clarity", | |
| "Logic demands coherence", | |
| "Logic preserves meaning", | |
| "Logic strengthens truth", | |
| "Logic clarifies necessity", | |
| "Logic enforces rationality", | |
| ]; | |
| interface LoginProps { | |
| onLogin: ( | |
| token: string, | |
| user: { username: string; name: string } | |
| ) => void; | |
| } | |
| const Login: React.FC<LoginProps> = ({ onLogin }) => { | |
| const [username, setUsername] = useState(''); | |
| const [password, setPassword] = useState(''); | |
| const [error, setError] = useState(''); | |
| const [loading, setLoading] = useState(false); | |
| const randomSaying = useMemo( | |
| () => LOGIC_SAYINGS[Math.floor(Math.random() * LOGIC_SAYINGS.length)], | |
| [] | |
| ); | |
| const GATEWAY_URL = import.meta.env.VITE_GATEWAY_URL || 'https://deepthoughtai-evo-gateway.hf.space'; | |
| const handleSubmit = async (e: React.FormEvent) => { | |
| e.preventDefault(); | |
| setError(''); | |
| setLoading(true); | |
| try { | |
| const endpoint = '/api/auth/login'; | |
| const body = { username, password }; | |
| const response = await fetch(`${GATEWAY_URL}${endpoint}`, { | |
| method: 'POST', | |
| credentials: 'include', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify(body), | |
| }); | |
| let data: any = {}; | |
| const contentType = response.headers.get('content-type') || ''; | |
| if (contentType.includes('application/json')) { | |
| data = await response.json(); | |
| } else { | |
| const text = await response.text(); | |
| data = { error: text || 'Authentication failed' }; | |
| } | |
| if (!response.ok) { | |
| throw new Error(data.error || 'Authentication failed'); | |
| } | |
| const sessionId = data.token || ''; | |
| onLogin(sessionId, data.user); | |
| } catch (err: any) { | |
| setError(err.message || 'An error occurred'); | |
| } finally { | |
| setLoading(false); | |
| } | |
| }; | |
| return ( | |
| <div className="login-page"> | |
| <div className="login-card"> | |
| <div className="login-brand"> | |
| <span className="login-logo">evo</span> | |
| <p className="login-tagline">Logical AI</p> | |
| </div> | |
| <form onSubmit={handleSubmit} className="login-form"> | |
| <div className="form-field"> | |
| <label htmlFor="username">Username</label> | |
| <input | |
| id="username" | |
| type="text" | |
| value={username} | |
| onChange={(e) => setUsername(e.target.value)} | |
| placeholder="Enter username" | |
| required | |
| autoComplete="username" | |
| autoFocus | |
| /> | |
| </div> | |
| <div className="form-field"> | |
| <label htmlFor="password">Password</label> | |
| <input | |
| id="password" | |
| type="password" | |
| value={password} | |
| onChange={(e) => setPassword(e.target.value)} | |
| placeholder="Enter password" | |
| required | |
| autoComplete="current-password" | |
| /> | |
| </div> | |
| {error && <div className="login-error">{error}</div>} | |
| <button type="submit" className="login-submit-btn" disabled={loading}> | |
| {loading ? 'Please wait...' : 'Sign In'} | |
| </button> | |
| </form> | |
| <div className="login-saying">{randomSaying}</div> | |
| <div style={{ textAlign: 'center', marginTop: '1rem' }}> | |
| <a | |
| href="https://machinelearning2014.github.io/" | |
| target="_blank" | |
| rel="noopener noreferrer" | |
| style={{ | |
| color: '#2dd4bf', | |
| fontSize: '0.82rem', | |
| textDecoration: 'underline', | |
| textUnderlineOffset: '2px', | |
| }} | |
| > | |
| {"Don't have an account? Register"} | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| }; | |
| export default Login; | |